xmpp-1.4.4/0000755000232200023220000000000013610066730013054 5ustar debalancedebalancexmpp-1.4.4/LICENSE.txt0000644000232200023220000002613613610066730014707 0ustar debalancedebalance Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. xmpp-1.4.4/README.md0000644000232200023220000004040613610066730014337 0ustar debalancedebalanceErlang/Elixir XMPP library ========================== [![Build Status](https://travis-ci.org/processone/xmpp.svg?branch=master)](https://travis-ci.org/processone/xmpp) [![Coverage Status](https://coveralls.io/repos/processone/xmpp/badge.svg?branch=master&service=github)](https://coveralls.io/github/processone/xmpp?branch=master) [![Hex version](https://img.shields.io/hexpm/v/xmpp.svg "Hex version")](https://hex.pm/packages/xmpp) The library provides comprehensive representation of XMPP elements as well as tools to work with them. Every such element is represented by an Erlang record. Most of the library's code is auto generated and thus considered to be bug free and efficient. The approach is very similar to [ASN.1](https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One), [Google Protocol Buffers](https://en.wikipedia.org/wiki/Protocol_Buffers) or [Apache Thrift](https://en.wikipedia.org/wiki/Apache_Thrift): an XML element is transformed into internal language structure (an Erlang record in our case) - the process known as "decoding". During decoding, validation is also performed, thus well-typed structures are generated, potentially decreasing bugs related to handcrafted parsing. A reverse process known as "encoding" is applied for transforming an Erlang record into an XML element. The library should be used along with [fast_xml](https://github.com/processone/fast_xml) library, because it is only able to decode from and encode to structures generated by that library (that is, `xmlel()` elements). **Table of Contents**: 1. [Status](#status) 2. [Compiling](#compiling) 3. [API](#api) 4. [Usage](#usage) 1. [Initialization and header files](#initialization-and-header-files) 2. [XMPP elements](#xmpp-elements) 3. [Decoding and encoding](#decoding-and-encoding) 4. [Stanzas](#stanzas) 1. [Common fields](#common-fields) 2. [Constructing stanza responses](#constructing-stanza-responses) 5. [Error elements](#error-elements) 6. [Text elements](#text-elements) 7. [Pretty printer](#pretty-printer) 8. [Namespaces](#namespaces) 9. [XMPP addresses](#xmpp-addresses) 10. [Language translation](#language-translation) 5. [Supported XMPP elements](#supported-xmpp-elements) # Status The library is considered as production ready and has been used in [ejabberd XMPP server](https://www.process-one.net/en/ejabberd) since version 16.12. However, the API is quite unstable so far and incompatibilities may be introduced from release to release. The stable API will be denoted by `2.x` tag in the future. # Dependency You need at least Erlang OTP 20. # Compiling As usual, the following commands are used to obtain and compile the library: ``` $ git clone https://github.com/processone/xmpp.git $ cd xmpp $ make ``` # API The full API is documented in [doc/API.md](doc/API.md) # Usage ## Initialization and header files Before calling any function from the library, `xmpp` application should be started. Although there are several header files which a developer might find useful to look into, they should **not** be included directly in the code. Only [include/xmpp.hrl](include/xmpp.hrl) file should be included, because it already includes all needed headers and also defines some useful macros. So the typical code should look like: ```erlang %% file: foo.erl -module(foo). -include_lib("xmpp/include/xmpp.hrl"). ... start() -> application:start(xmpp), ... ``` ## XMPP elements All XMPP elements (records) are defined in [include/xmpp_codec.hrl](include/xmpp_codec.hrl) file. For convenience, every record has the corresponding type spec. There is also predefined `xmpp_element()` type which is a container for all defined record types: so sometimes we will refer to an arbitrary XMPP element as `xmpp_element()` in the rest of this document. These records are generated automatically by [XML generator](https://github.com/processone/fast_xml/blob/master/src/fxml_gen.erl) from specification file [specs/xmpp_codec.spec](specs/xmpp_codec.spec). The specification file contains information about XML elements defined within XMPP related namespace. > **TODO**: writing specs for new elements will be documented later. For now > you can learn by example: pick up a spec of any element which is very close > to the one you want to add a spec for and use it as a pattern > **WARNING**: you should **not** include `xmpp_codec.hrl` in your erlang code. > Include `xmpp.hrl` instead. `xmpp_codec.hrl` should be only used to > consult definitions of existing XMPP elements. ## Decoding and encoding Once an `xmlel()` element is obtained (either using `fxml_stream:parse_element/1` function or by any other means), it can be decoded using either [decode/1](doc/API.md#decode1) or [decode/3](doc/API.md#decode3) functions. The result will be an XMPP element. Note that decoding might fail if there is no known XMPP element for the provided `xmlel()` element, or `xmlel()` is invalid, so you should call these functions inside `try ... catch`. Exceptions returned during decoding can be formatted using [format_error/1](doc/API.md#format_error1) or [io_format_error/1](doc/API.md#io_format_error1) functions. **Example**: ```erlang handle(#iq{type = get, sub_els = [El]} = IQ) -> try xmpp:decode(El) of Pkt -> handle_iq_child_element(Pkt) catch _:{xmpp_codec, Reason} -> Txt = xmpp:format_error(Reason), io:format("iq has malformed child element: ~s", [Txt]), handle_iq_with_malformed_child_element(IQ) end. ``` [encode/1](doc/API.md#encode1) and [encode/2](doc/API.md#encode2) functions can be used for reverse transformation, i.e. to encode an XMPP element into `xmlel()` element. Encoding would never fail as long as provided XMPP element is valid. ## Stanzas Amongst all XMPP elements defined in the library, the most notable ones are stanzas: `message()`, `presence()` and `iq()` elements. A large part of `xmpp` module deals with stanzas. ### Common fields Records of all stanzas have several common fields: `id`, `type`, `lang`, `from`, `to`, `sub_els` and `meta`. Although it's acceptable to manipulate with these fields directly (which is useful in pattern matching, for example), `xmpp` module provides several functions to work with them: - `id`: [get_id/1](doc/API.md#get_id1) and [set_id/2](doc/API.md#set_id2) can be used - `type`: [get_type/1](doc/API.md#get_type1) and [set_type/2](doc/API.md#set_type2) can be used - `lang`: [get_lang/1](doc/API.md#get_lang1) and [set_lang/2](doc/API.md#set_lang2) can be used - `from` and `to`: [get_from/1](doc/API.md#get_from1), [get_to/1](doc/API.md#get_to1), [set_from/2](doc/API.md#set_from2), [set_to/2](doc/API.md#set_to2) and [set_from_to/3](doc/API.md#set_from_to3) can be used - `sub_els`: [get_els/1](doc/API.md#get_els1) and [set_els/2](doc/API.md#set_els2) can be used; additional functions to work with subtags directly are: [set_subtag/2](doc/API.md#set_subtag2), [get_subtag/2](doc/API.md#get_subtag2), [get_subtags/2](doc/API.md#get_subtags2), [try_subtag/2](doc/API.md#try_subtag2), [try_subtags/2](doc/API.md#try_subtags2), [remove_subtag/2](doc/API.md#remove_subtag2), [has_subtag/2](doc/API.md#has_subtag2), and [append_subtags/2](doc/API.md#append_subtags2). - `meta`: this field is intended for attaching arbitrary Erlang terms to stanzas; the field is represented by a `map()` and can be manipulated using standard [maps](http://erlang.org/doc/man/maps.html) module, but also using the following functions: [get_meta/1](doc/API.md#get_meta1), [get_meta/2](doc/API.md#get_meta2), [get_meta/3](doc/API.md#get_meta3), [set_meta/2](doc/API.md#set_meta2), [put_meta/3](doc/API.md#put_meta3), [update_meta/3](doc/API.md#update_meta3) and [del_meta/2](doc/API.md#del_meta2) ### Constructing stanza responses For creating `iq()` replies the following functions exist: [make_iq_result/1](doc/API.md#make_iq_result1) and [make_iq_result/2](doc/API.md#make_iq_result2). These two functions are `iq()` specific and create `iq()` elements of type `result` only. To create an error response from an arbitrary stanza (including `iq()`) [make_error/2](doc/API.md#make_error2) function can be used. ## Error elements A series of functions is provided by `xmpp` module for constructing `stanza_error()` or `stream_error()` elements. To construct `stanza_error()` elements the functions with `err_` prefix can be used, such as [err_bad_request/0](doc/API.md#err_bad_request0) or [err_internal_server_error/2](doc/API.md#err_internal_server_error2). To construct `stream_error()` elements the functions with `serr_` prefix can be used, such as [serr_not_well_formed/0](doc/API.md#serr_not_well_formed0) or [serr_invalid_from/2](doc/API.md#serr_invalid_from2). ## Text elements The text element is represented by `#text{}` record (of `text()` type). Some record fields, such as `#message.body` or `#presence.status`, contain a list of text elements (i.e. `[text()]`). To avoid writting a lot of extracting code the following functions can be used to manipulate with `text()` elements: [get_text/1](doc/API.md#get_text1), [get_text/2](doc/API.md#get_text2), [mk_text/1](doc/API.md#mk_text1) and [mk_text/2](doc/API.md#mk_text2). ## Pretty printer For pretty printing of XMPP elements (for example, for dumping elements in the log in a more readable form), [pp/1](doc/API.md#pp1) function can be used. ## Namespaces There are many predefined macros for XMPP specific XML namespaces defined in [include/ns.hrl](include/ns.hrl) such as `?NS_CLIENT` or `?NS_ROSTER`. > **WARNING**: you should **not** include `ns.hrl` in your erlang code. > Include `xmpp.hrl` instead. Consult this file only to obtain a macro > name for the required namespace. There is also [get_ns/1](doc/API.md#get_ns1) function which can be used to obtain a namespace of `xmpp_element()` or from `xmlel()` element. ## XMPP addresses An XMPP address (aka Jabber ID or JID) can be represented using two types: - `jid()`: a JID is represented by a record `#jid{}`. This type is used to represent JIDs in XMPP elements. - `ljid()`: a JID is represented by a tuple `{User, Server, Resource}` where `User`, `Server` and `Resource` are stringprepped version of a nodepart, namepart and resourcepart of a JID respectively. This representation is useful for JIDs comparison and when a JID should be used as a key (in a Mnesia database, ETS table, etc.) Both types and the record are defined in [include/jid.hrl](include/jid.hrl). > **WARNING**: you should **not** include `jid.hrl` in your erlang code. > Include `xmpp.hrl` instead. Functions for working with JIDs are provided by [jid](doc/API.md#jid) module. ## Language translation The library uses a callback function in order to perform language translation. The translation is applied when constructing [text](#text-elements) or [error](#error-elements) elements. To set the callback one can use [set_tr_callback/1](doc/API.md#set_tr_callback1) function. By default, no translation is performed. # Supported XMPP elements XMPP elements from the following documents are supported: - [RFC 6120](https://tools.ietf.org/html/rfc6120): XMPP Core - [RFC 6121](https://tools.ietf.org/html/rfc6121): XMPP Instant Messaging and Presence - [XEP-0004](https://xmpp.org/extensions/xep-0004.html): Data Forms - [XEP-0012](https://xmpp.org/extensions/xep-0012.html): Last Activity - [XEP-0013](https://xmpp.org/extensions/xep-0013.html): Flexible Offline Message Retrieval - [XEP-0016](https://xmpp.org/extensions/xep-0016.html): Privacy Lists - [XEP-0022](https://xmpp.org/extensions/xep-0022.html): Message Events - [XEP-0023](https://xmpp.org/extensions/xep-0023.html): Message Expiration - [XEP-0030](https://xmpp.org/extensions/xep-0030.html): Service Discovery - [XEP-0033](https://xmpp.org/extensions/xep-0033.html): Extended Stanza Addressing - [XEP-0039](https://xmpp.org/extensions/xep-0039.html): Statistics Gathering - [XEP-0045](https://xmpp.org/extensions/xep-0045.html): Multi-User Chat - [XEP-0047](https://xmpp.org/extensions/xep-0047.html): In-Band Bytestreams - [XEP-0048](https://xmpp.org/extensions/xep-0048.html): Bookmarks - [XEP-0049](https://xmpp.org/extensions/xep-0049.html): Private XML Storage - [XEP-0050](https://xmpp.org/extensions/xep-0050.html): Ad-Hoc Commands - [XEP-0054](https://xmpp.org/extensions/xep-0054.html): vcard-temp - [XEP-0055](https://xmpp.org/extensions/xep-0055.html): Jabber Search - [XEP-0059](https://xmpp.org/extensions/xep-0059.html): Result Set Management - [XEP-0060](https://xmpp.org/extensions/xep-0060.html): Publish-Subscribe - [XEP-0065](https://xmpp.org/extensions/xep-0065.html): SOCKS5 Bytestreams - [XEP-0066](https://xmpp.org/extensions/xep-0066.html): Out of Band Data - [XEP-0077](https://xmpp.org/extensions/xep-0077.html): In-Band Registration - [XEP-0078](https://xmpp.org/extensions/xep-0078.html): Non-SASL Authentication - [XEP-0084](https://xmpp.org/extensions/xep-0084.html): User Avatar - [XEP-0085](https://xmpp.org/extensions/xep-0085.html): Chat State Notifications - [XEP-0092](https://xmpp.org/extensions/xep-0092.html): Software Version - [XEP-0114](https://xmpp.org/extensions/xep-0114.html): Jabber Component Protocol - [XEP-0115](https://xmpp.org/extensions/xep-0115.html): Entity Capabilities - [XEP-0131](https://xmpp.org/extensions/xep-0131.html): Stanza Headers and Internet Metadata - [XEP-0138](https://xmpp.org/extensions/xep-0138.html): Stream Compression - [XEP-0153](https://xmpp.org/extensions/xep-0153.html): vCard-Based Avatars - [XEP-0158](https://xmpp.org/extensions/xep-0158.html): CAPTCHA Forms - [XEP-0166](https://xmpp.org/extensions/xep-0166.html): Jingle - [XEP-0172](https://xmpp.org/extensions/xep-0172.html): User Nickname - [XEP-0184](https://xmpp.org/extensions/xep-0184.html): Message Delivery Receipts - [XEP-0191](https://xmpp.org/extensions/xep-0191.html): Blocking Command - [XEP-0198](https://xmpp.org/extensions/xep-0198.html): Stream Management - [XEP-0199](https://xmpp.org/extensions/xep-0199.html): XMPP Ping - [XEP-0202](https://xmpp.org/extensions/xep-0202.html): Entity Time - [XEP-0203](https://xmpp.org/extensions/xep-0203.html): Delayed Delivery - [XEP-0220](https://xmpp.org/extensions/xep-0220.html): Server Dialback - [XEP-0221](https://xmpp.org/extensions/xep-0221.html): Data Forms Media Element - [XEP-0231](https://xmpp.org/extensions/xep-0231.html): Bits of Binary - [XEP-0234](https://xmpp.org/extensions/xep-0234.html): Jingle File Transfer - [XEP-0249](https://xmpp.org/extensions/xep-0249.html): Direct MUC Invitations - [XEP-0260](https://xmpp.org/extensions/xep-0260.html): Jingle SOCKS5 Bytestreams Transport Method - [XEP-0261](https://xmpp.org/extensions/xep-0261.html): Jingle In-Band Bytestreams Transport Method - [XEP-0264](https://xmpp.org/extensions/xep-0264.html): Jingle Content Thumbnails - [XEP-0279](https://xmpp.org/extensions/xep-0279.html): Server IP Check - [XEP-0280](https://xmpp.org/extensions/xep-0280.html): Message Carbons - [XEP-0297](https://xmpp.org/extensions/xep-0297.html): Stanza Forwarding - [XEP-0300](https://xmpp.org/extensions/xep-0300.html): Use of Cryptographic Hash Functions in XMPP - [XEP-0313](https://xmpp.org/extensions/xep-0313.html): Message Archive Management - [XEP-0319](https://xmpp.org/extensions/xep-0319.html): Last User Interaction in Presence - [XEP-0328](https://xmpp.org/extensions/xep-0328.html): JID Prep - [XEP-0334](https://xmpp.org/extensions/xep-0334.html): Message Processing Hints - [XEP-0352](https://xmpp.org/extensions/xep-0352.html): Client State Indication - [XEP-0355](https://xmpp.org/extensions/xep-0355.html): Namespace Delegation - [XEP-0356](https://xmpp.org/extensions/xep-0356.html): Privileged Entity - [XEP-0357](https://xmpp.org/extensions/xep-0357.html): Push Notifications - [XEP-0359](https://xmpp.org/extensions/xep-0359.html): Unique and Stable Stanza IDs - [XEP-0363](https://xmpp.org/extensions/xep-0363.html): HTTP File Upload - [XEP-0369](https://xmpp.org/extensions/xep-0369.html): Mediated Information eXchange (MIX) - [XEP-0377](https://xmpp.org/extensions/xep-0377.html): Spam Reporting - [XEP-0405](https://xmpp.org/extensions/xep-0405.html): MIX: Participant Server Requirements - [XEP-0417](https://xmpp.org/extensions/xep-0417.html): E2E Authentication in XMPP: Certificate Issuance and Revocation - [draft-cridland-xmpp-session-01](https://tools.ietf.org/html/draft-cridland-xmpp-session-01): XMPP Session Establishment As well as some proprietary extensions from [ProcessOne](https://www.process-one.net) xmpp-1.4.4/asn1/0000755000232200023220000000000013610066730013716 5ustar debalancedebalancexmpp-1.4.4/asn1/XmppAddr.asn10000644000232200023220000000057713610066730016232 0ustar debalancedebalanceXmppAddr { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) id-on(8) id-on-xmppAddr(5) } DEFINITIONS EXPLICIT TAGS ::= BEGIN id-on-xmppAddr OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) id-on(8) 5 } XmppAddr ::= UTF8String END xmpp-1.4.4/specs/0000755000232200023220000000000013610066730014171 5ustar debalancedebalancexmpp-1.4.4/specs/http_upload.cfg0000644000232200023220000000022313610066730017172 0ustar debalancedebalance[{decode, [{<<"max-file-size">>, {dec_int, [0, infinity]}}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/push_summary.xdata0000644000232200023220000000124613610066730017753 0ustar debalancedebalance urn:xmpp:push:summary XEP-0357 Provides summarizing information about a user for use in push notifications. xmpp-1.4.4/specs/pubsub_node_config.xdata0000644000232200023220000001575513610066730021063 0ustar debalancedebalance http://jabber.org/protocol/pubsub#node_config XEP-0060 Forms enabling configuration of pubsub nodes true 1 xmpp-1.4.4/specs/muc_roomconfig.xdata0000644000232200023220000001300213610066730020216 0ustar debalancedebalance http://jabber.org/protocol/muc#roomconfig XEP-0045 Forms enabling creation and configuration of a Multi-User Chat (MUC) room. xmpp-1.4.4/specs/pubsub_meta_data.xdata0000644000232200023220000000504413610066730020516 0ustar debalancedebalance http://jabber.org/protocol/pubsub#meta-data XEP-0060 Forms enabling setting of metadata information about pubsub nodes xmpp-1.4.4/specs/muc_register.xdata0000644000232200023220000000163413610066730017710 0ustar debalancedebalance http://jabber.org/protocol/muc#register XEP-0045 Forms enabling user registration with a Multi-User Chat (MUC) room or admin approval of user registration requests. xmpp-1.4.4/specs/muc_request.xdata0000644000232200023220000000131313610066730017546 0ustar debalancedebalance http://jabber.org/protocol/muc#request XEP-0045 Forms enabling voice requests in a Multi-User Chat (MUC) room or admin approval of such requests. xmpp-1.4.4/specs/pubsub_subscribe_options.cfg0000644000232200023220000000003313610066730021762 0ustar debalancedebalance[{prefix, <<"pubsub#">>}]. xmpp-1.4.4/specs/pubsub_node_config.cfg0000644000232200023220000000035513610066730020507 0ustar debalancedebalance[{prefix, <<"pubsub#">>}, {decode, [{<<"pubsub#max_items">>, {dec_int, [0,infinity]}}, {<<"pubsub#max_payload_size">>, {dec_int, [0,infinity]}}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/pubsub_subscribe_options.xdata0000644000232200023220000000440313610066730022331 0ustar debalancedebalance http://jabber.org/protocol/pubsub#subscribe_options XEP-0060 Forms enabling configuration of subscription options for pubsub nodes xmpp-1.4.4/specs/flex_offline.xdata0000644000232200023220000000047013610066730017655 0ustar debalancedebalance http://jabber.org/protocol/offline XEP-0013 Service Discovery extension for number of messages in an offline message queue. xmpp-1.4.4/specs/muc_request.cfg0000644000232200023220000000006713610066730017211 0ustar debalancedebalance[{prefix, <<"muc#">>}, {required, [<<"muc#role">>]}]. xmpp-1.4.4/specs/flex_offline.cfg0000644000232200023220000000010413610066730017305 0ustar debalancedebalance[{decode, [{<<"number_of_messages">>, {dec_int, [0, infinity]}}]}]. xmpp-1.4.4/specs/pubsub_publish_options.cfg0000644000232200023220000000015713610066730021456 0ustar debalancedebalance[{prefix, <<"pubsub#">>}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/pubsub_get_pending.xdata0000644000232200023220000000053413610066730021061 0ustar debalancedebalance http://jabber.org/protocol/pubsub#subscribe_authorization XEP-0060 Forms enabling authorization of subscriptions to pubsub nodes xmpp-1.4.4/specs/mam_query.cfg0000644000232200023220000000043713610066730016655 0ustar debalancedebalance[{decode, [{<<"start">>, {xmpp_util, decode_timestamp, []}}, {<<"end">>, {xmpp_util, decode_timestamp, []}}]}, {specs, [{<<"start">>, "erlang:timestamp()"}, {<<"end">>, "erlang:timestamp()"}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/pubsub_subscribe_authorization.cfg0000644000232200023220000000030213610066730023166 0ustar debalancedebalance[{prefix, <<"pubsub#">>}, {required, [<<"pubsub#node">>, <<"pubsub#subscriber_jid">>, <<"pubsub#allow">>]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/muc_register.cfg0000644000232200023220000000011513610066730017337 0ustar debalancedebalance[{prefix, <<"muc#register_">>}, {required, [<<"muc#register_roomnick">>]}]. xmpp-1.4.4/specs/http_upload.xdata0000644000232200023220000000056513610066730017545 0ustar debalancedebalance urn:xmpp:http:upload:0 urn:xmpp:http:upload eu:siacs:conversations:http:upload XEP-0363 Information about HTTP File Upload service xmpp-1.4.4/specs/captcha_form.cfg0000644000232200023220000000026213610066730017300 0ustar debalancedebalance[{decode, [{<<"answers">>, {dec_int, [0, infinity]}}, {<<"from">>, {jid, decode, []}}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/pubsub_subscribe_authorization.xdata0000644000232200023220000000126513610066730023541 0ustar debalancedebalance http://jabber.org/protocol/pubsub#subscribe_authorization XEP-0060 Forms enabling authorization of subscriptions to pubsub nodes xmpp-1.4.4/specs/muc_roominfo.cfg0000644000232200023220000000066313610066730017353 0ustar debalancedebalance[{prefix, <<"muc#roominfo_">>}, {prefix, <<"muc#roomconfig_">>}, {prefix, <<"muc#">>}, {decode, [{<<"muc#maxhistoryfetch">>, {dec_int, [0, infinity]}}, {<<"muc#roominfo_pubsub">>, {xmpp_uri, check, []}}, {<<"muc#roominfo_lang">>, {xmpp_lang, check, []}}, {<<"muc#roominfo_occupants">>, {dec_int, [0, infinity]}}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/pubsub_get_pending.cfg0000644000232200023220000000022113610066730020510 0ustar debalancedebalance[{prefix, <<"pubsub#">>}, {required, [<<"pubsub#node">>]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/xmpp_codec.spec0000644000232200023220000057213513610066730017203 0ustar debalancedebalance -record(text, {lang = <<>> :: binary(), data = <<>> :: binary()}). -type text() :: #text{}. -xml(jidprep, #elem{name = <<"jid">>, xmlns = <<"urn:xmpp:jidprep:0">>, module = 'xep0328', result = {jidprep, '$jid'}, cdata = #cdata{label = '$jid', required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}}). -xml(last, #elem{name = <<"query">>, xmlns = <<"jabber:iq:last">>, module = 'xep0012', result = {last, '$seconds', '$status'}, attrs = [#attr{name = <<"seconds">>, enc = {enc_int, []}, dec = {dec_int, [0, infinity]}}], cdata = #cdata{default = <<"">>, label = '$status'}}). -xml(version_name, #elem{name = <<"name">>, xmlns = <<"jabber:iq:version">>, module = 'xep0092', result = '$cdata', cdata = #cdata{label = '$cdata', required = true}}). -xml(version_ver, #elem{name = <<"version">>, xmlns = <<"jabber:iq:version">>, module = 'xep0092', result = '$cdata', cdata = #cdata{label = '$cdata', required = true}}). -xml(version_os, #elem{name = <<"os">>, xmlns = <<"jabber:iq:version">>, module = 'xep0092', result = '$cdata', cdata = #cdata{label = '$cdata', required = true}}). -xml(version, #elem{name = <<"query">>, xmlns = <<"jabber:iq:version">>, module = 'xep0092', result = {version, '$name', '$ver', '$os'}, refs = [#ref{name = version_name, label = '$name', min = 0, max = 1}, #ref{name = version_ver, label = '$ver', min = 0, max = 1}, #ref{name = version_os, label = '$os', min = 0, max = 1}]}). -xml(roster_group, #elem{name = <<"group">>, xmlns = <<"jabber:iq:roster">>, module = rfc6121, result = '$cdata', cdata = #cdata{required = true, label = '$cdata'}}). -xml(roster_item, #elem{name = <<"item">>, xmlns = <<"jabber:iq:roster">>, module = rfc6121, result = {roster_item, '$jid', '$name', '$groups', '$subscription', '$ask'}, attrs = [#attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"name">>, default = <<"">>}, #attr{name = <<"subscription">>, default = none, enc = {enc_enum, []}, dec = {dec_enum, [[none,to,from,both,remove]]}}, #attr{name = <<"ask">>, enc = {enc_enum, []}, dec = {dec_enum, [[subscribe]]}}], refs = [#ref{name = roster_group, label = '$groups'}]}). -xml(roster_query, #elem{name = <<"query">>, xmlns = <<"jabber:iq:roster">>, module = rfc6121, result = {roster_query, '$items', '$ver'}, attrs = [#attr{name = <<"ver">>, default = undefined}], refs = [#ref{name = roster_item, label = '$items'}]}). -xml(rosterver_feature, #elem{name = <<"ver">>, xmlns = <<"urn:xmpp:features:rosterver">>, module = rfc6121, result = {rosterver_feature}}). -xml(privacy_message, #elem{name = <<"message">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = true}). -xml(privacy_iq, #elem{name = <<"iq">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = true}). -xml(privacy_presence_in, #elem{name = <<"presence-in">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = true}). -xml(privacy_presence_out, #elem{name = <<"presence-out">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = true}). -xml(privacy_item, #elem{name = <<"item">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = {privacy_item, '$order', '$action', '$type', '$value', '$message', '$iq', '$presence_in', '$presence_out'}, attrs = [#attr{name = <<"action">>, required = true, dec = {dec_enum, [[allow, deny]]}, enc = {enc_enum, []}}, #attr{name = <<"order">>, required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"type">>, dec = {dec_enum, [[group, jid, subscription]]}, enc = {enc_enum, []}}, #attr{name = <<"value">>}], refs = [#ref{name = privacy_message, default = false, min = 0, max = 1, label = '$message'}, #ref{name = privacy_iq, default = false, min = 0, max = 1, label = '$iq'}, #ref{name = privacy_presence_in, default = false, min = 0, max = 1, label = '$presence_in'}, #ref{name = privacy_presence_out, default = false, min = 0, max = 1, label = '$presence_out'}]}). -xml(privacy_list, #elem{name = <<"list">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = {privacy_list, '$name', '$items'}, attrs = [#attr{name = <<"name">>, required = true}], refs = [#ref{name = privacy_item, label = '$items'}]}). -xml(privacy_default_list, #elem{name = <<"default">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = '$name', attrs = [#attr{name = <<"name">>, default = none}]}). -xml(privacy_active_list, #elem{name = <<"active">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = '$name', attrs = [#attr{name = <<"name">>, default = none}]}). -xml(privacy, #elem{name = <<"query">>, xmlns = <<"jabber:iq:privacy">>, module = 'xep0016', result = {privacy_query, '$lists', '$default', '$active'}, refs = [#ref{name = privacy_list, label = '$lists'}, #ref{name = privacy_default_list, min = 0, max = 1, label = '$default'}, #ref{name = privacy_active_list, min = 0, max = 1, label = '$active'}]}). -xml(block_item, #elem{name = <<"item">>, xmlns = <<"urn:xmpp:blocking">>, module = 'xep0191', result = {block_item, '$jid', '$spam_report'}, attrs = [#attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = report, label = '$spam_report', min = 0, max = 1}]}). -xml(block, #elem{name = <<"block">>, xmlns = <<"urn:xmpp:blocking">>, module = 'xep0191', result = {block, '$items'}, refs = [#ref{name = block_item, label = '$items'}]}). -xml(unblock, #elem{name = <<"unblock">>, xmlns = <<"urn:xmpp:blocking">>, module = 'xep0191', result = {unblock, '$items'}, refs = [#ref{name = block_item, label = '$items'}]}). -xml(block_list, #elem{name = <<"blocklist">>, xmlns = <<"urn:xmpp:blocking">>, module = 'xep0191', result = {block_list, '$items'}, refs = [#ref{name = block_item, label = '$items'}]}). -xml(report_reason_abuse, #elem{name = <<"abuse">>, xmlns = <<"urn:xmpp:reporting:0">>, module = 'xep0377', result = 'abuse'}). -xml(report_reason_spam, #elem{name = <<"spam">>, xmlns = <<"urn:xmpp:reporting:0">>, module = 'xep0377', result = 'spam'}). -xml(report_text, #elem{name = <<"text">>, xmlns = <<"urn:xmpp:reporting:0">>, module = 'xep0377', result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(report, #elem{name = <<"report">>, xmlns = <<"urn:xmpp:reporting:0">>, module = 'xep0377', result = {report, '$reason', '$text'}, refs = [#ref{name = report_reason_abuse, label = '$reason', min = 0, max = 1}, #ref{name = report_reason_spam, label = '$reason', min = 0, max = 1}, #ref{name = report_text, label = '$text'}]}). -xml(disco_identity, #elem{name = <<"identity">>, xmlns = <<"http://jabber.org/protocol/disco#info">>, module = 'xep0030', result = {identity, '$category', '$type', '$lang', '$name'}, attrs = [#attr{name = <<"category">>, required = true}, #attr{name = <<"type">>, required = true}, #attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}, #attr{name = <<"name">>}]}). -xml(disco_feature, #elem{name = <<"feature">>, xmlns = <<"http://jabber.org/protocol/disco#info">>, module = 'xep0030', result = '$var', attrs = [#attr{name = <<"var">>, required = true}]}). -xml(disco_info, #elem{name = <<"query">>, xmlns = <<"http://jabber.org/protocol/disco#info">>, module = 'xep0030', result = {disco_info, '$node', '$identities', '$features', '$xdata'}, attrs = [#attr{name = <<"node">>}], refs = [#ref{name = disco_identity, label = '$identities'}, #ref{name = disco_feature, label = '$features'}, #ref{name = xdata, label = '$xdata'}]}). -xml(disco_item, #elem{name = <<"item">>, xmlns = <<"http://jabber.org/protocol/disco#items">>, module = 'xep0030', result = {disco_item, '$jid', '$name', '$node'}, attrs = [#attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}, required = true}, #attr{name = <<"name">>}, #attr{name = <<"node">>}]}). -xml(disco_items, #elem{name = <<"query">>, xmlns = <<"http://jabber.org/protocol/disco#items">>, module = 'xep0030', result = {disco_items, '$node', '$items', '$rsm'}, attrs = [#attr{name = <<"node">>}], refs = [#ref{name = disco_item, label = '$items'}, #ref{name = rsm_set, min = 0, max = 1, label = '$rsm'}]}). -xml(private, #elem{name = <<"query">>, xmlns = <<"jabber:iq:private">>, module = 'xep0049', ignore_els = true, result = {private, '$_els'}}). -xml(conference_nick, #elem{name = <<"nick">>, xmlns = <<"storage:bookmarks">>, module = 'xep0048', result = '$cdata'}). -xml(conference_password, #elem{name = <<"password">>, xmlns = <<"storage:bookmarks">>, module = 'xep0048', result = '$cdata'}). -xml(bookmark_conference, #elem{name = <<"conference">>, xmlns = <<"storage:bookmarks">>, module = 'xep0048', result = {bookmark_conference, '$name', '$jid', '$autojoin', '$nick', '$password'}, attrs = [#attr{name = <<"name">>, required = true}, #attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"autojoin">>, default = false, dec = {dec_bool, []}, enc = {enc_bool, []}}], refs = [#ref{name = conference_nick, label = '$nick', min = 0, max = 1}, #ref{name = conference_password, label = '$password', min = 0, max = 1}]}). -xml(bookmark_url, #elem{name = <<"url">>, xmlns = <<"storage:bookmarks">>, module = 'xep0048', result = {bookmark_url, '$name', '$url'}, attrs = [#attr{name = <<"name">>, required = true}, #attr{name = <<"url">>, required = true}]}). -xml(bookmarks_storage, #elem{name = <<"storage">>, xmlns = <<"storage:bookmarks">>, module = 'xep0048', result = {bookmark_storage, '$conference', '$url'}, refs = [#ref{name = bookmark_conference, label = '$conference'}, #ref{name = bookmark_url, label = '$url'}]}). -xml(stat_error, #elem{name = <<"error">>, xmlns = <<"http://jabber.org/protocol/stats">>, module = 'xep0039', result = {stat_error, '$code', '$reason'}, cdata = #cdata{default = <<"">>, label = '$reason'}, attrs = [#attr{name = <<"code">>, required = true, enc = {enc_int, []}, dec = {dec_int, []}}]}). -xml(stat, #elem{name = <<"stat">>, xmlns = <<"http://jabber.org/protocol/stats">>, module = 'xep0039', result = {stat, '$name', '$units', '$value', '$error'}, attrs = [#attr{name = <<"name">>, required = true}, #attr{name = <<"units">>, default = <<"">>}, #attr{name = <<"value">>, default = <<"">>}], refs = [#ref{name = stat_error, label = '$error', min = 0, max = 1}]}). -xml(stats, #elem{name = <<"query">>, xmlns = <<"http://jabber.org/protocol/stats">>, module = 'xep0039', result = {stats, '$list', '$node'}, attrs = [#attr{name = <<"node">>, default = <<"">>}], refs = [#ref{name = stat, label = '$list'}]}). -type iq_type() :: get | set | result | error. -type message_type() :: chat | error | groupchat | headline | normal. -type presence_type() :: available | error | probe | subscribe | subscribed | unavailable | unsubscribe | unsubscribed. -record(iq, {id = <<>> :: binary(), type :: iq_type(), lang = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid(), sub_els = [] :: [xmpp_element() | fxml:xmlel()], meta = #{} :: map()}). -type iq() :: #iq{}. -xml(iq, #elem{name = <<"iq">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {iq, '$id', '$type', '$lang', '$from', '$to', '$_els', '$_'}, attrs = [#attr{name = <<"id">>, required = true}, #attr{name = <<"type">>, required = true, enc = {enc_enum, []}, dec = {dec_enum, [[get, set, result, error]]}}, #attr{name = <<"from">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"to">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(message_subject, #elem{name = <<"subject">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(message_body, #elem{name = <<"body">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(message_thread, #elem{name = <<"thread">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {message_thread, '$parent', '$data'}, attrs = [#attr{name = <<"parent">>}], cdata = #cdata{label = '$data'}}). -record(message, {id = <<>> :: binary(), type = normal :: message_type(), lang = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid(), subject = [] :: [#text{}], body = [] :: [#text{}], thread :: undefined | message_thread(), sub_els = [] :: [xmpp_element() | fxml:xmlel()], meta = #{} :: map()}). -type message() :: #message{}. -xml(message, #elem{name = <<"message">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {message, '$id', '$type', '$lang', '$from', '$to', '$subject', '$body', '$thread', '$_els', '$_'}, attrs = [#attr{name = <<"id">>}, #attr{name = <<"type">>, default = normal, enc = {enc_enum, []}, dec = {dec_message_type, []}}, #attr{name = <<"from">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"to">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}], refs = [#ref{name = message_subject, label = '$subject'}, #ref{name = message_thread, min = 0, max = 1, label = '$thread'}, #ref{name = message_body, label = '$body'}]}). -xml(presence_show, #elem{name = <<"show">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = '$cdata', cdata = #cdata{enc = {enc_enum, []}, dec = {dec_enum, [[away, chat, dnd, xa]]}}}). -xml(presence_status, #elem{name = <<"status">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(presence_priority, #elem{name = <<"priority">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = '$cdata', cdata = #cdata{enc = {enc_int, []}, dec = {dec_int, []}}}). -record(presence, {id = <<>> :: binary(), type = available :: presence_type(), lang = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid(), show :: undefined | 'away' | 'chat' | 'dnd' | 'xa', status = [] :: [#text{}], priority :: undefined | integer(), sub_els = [] :: [xmpp_element() | fxml:xmlel()], meta = #{} :: map()}). -type presence() :: #presence{}. -xml(presence, #elem{name = <<"presence">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {presence, '$id', '$type', '$lang', '$from', '$to', '$show', '$status', '$priority', '$_els', '$_'}, attrs = [#attr{name = <<"id">>}, #attr{name = <<"type">>, default = available, enc = {enc_enum, []}, dec = {dec_enum, [[unavailable, subscribe, subscribed, unsubscribe, unsubscribed, available, probe, error]]}}, #attr{name = <<"from">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"to">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}], refs = [#ref{name = presence_show, min = 0, max = 1, label = '$show'}, #ref{name = presence_status, label = '$status'}, #ref{name = presence_priority, min = 0, max = 1, label = '$priority'}]}). -xml(error_bad_request, #elem{name = <<"bad-request">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'bad-request'}). -xml(error_conflict, #elem{name = <<"conflict">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'conflict'}). -xml(error_feature_not_implemented, #elem{name = <<"feature-not-implemented">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'feature-not-implemented'}). -xml(error_forbidden, #elem{name = <<"forbidden">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'forbidden'}). -xml(error_gone, #elem{name = <<"gone">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, cdata = #cdata{label = '$uri'}, result = {'gone', '$uri'}}). -xml(error_internal_server_error, #elem{name = <<"internal-server-error">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'internal-server-error'}). -xml(error_item_not_found, #elem{name = <<"item-not-found">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'item-not-found'}). -xml(error_jid_malformed, #elem{name = <<"jid-malformed">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'jid-malformed'}). -xml(error_not_acceptable, #elem{name = <<"not-acceptable">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'not-acceptable'}). -xml(error_not_allowed, #elem{name = <<"not-allowed">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'not-allowed'}). -xml(error_not_authorized, #elem{name = <<"not-authorized">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'not-authorized'}). -xml(error_payment_required, #elem{name = <<"payment-required">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'payment-required'}). -xml(error_policy_violation, #elem{name = <<"policy-violation">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'policy-violation'}). -xml(error_recipient_unavailable, #elem{name = <<"recipient-unavailable">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'recipient-unavailable'}). -xml(error_redirect, #elem{name = <<"redirect">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, cdata = #cdata{label = '$uri'}, result = {'redirect', '$uri'}}). -xml(error_registration_required, #elem{name = <<"registration-required">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'registration-required'}). -xml(error_remote_server_not_found, #elem{name = <<"remote-server-not-found">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'remote-server-not-found'}). -xml(error_remote_server_timeout, #elem{name = <<"remote-server-timeout">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'remote-server-timeout'}). -xml(error_resource_constraint, #elem{name = <<"resource-constraint">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'resource-constraint'}). -xml(error_service_unavailable, #elem{name = <<"service-unavailable">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'service-unavailable'}). -xml(error_subscription_required, #elem{name = <<"subscription-required">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'subscription-required'}). -xml(error_undefined_condition, #elem{name = <<"undefined-condition">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'undefined-condition'}). -xml(error_unexpected_request, #elem{name = <<"unexpected-request">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, result = 'unexpected-request'}). -xml(error_text, #elem{name = <<"text">>, result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, xmlns = <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, module = rfc6120, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(error, #elem{name = <<"error">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {stanza_error, '$type', '$code', '$by', '$reason', '$text', '$_els'}, attrs = [#attr{name = <<"type">>, label = '$type', required = true, dec = {dec_enum, [[auth, cancel, continue, modify, wait]]}, enc = {enc_enum, []}}, #attr{name = <<"code">>, label = '$code', enc = {enc_int, []}, dec = {dec_int, [0, infinity]}}, #attr{name = <<"by">>, label = '$by', enc = {jid, encode, []}, dec = {jid, decode, []}}], refs = [#ref{name = error_text, label = '$text'}, #ref{name = error_bad_request, min = 0, max = 1, label = '$reason'}, #ref{name = error_conflict, min = 0, max = 1, label = '$reason'}, #ref{name = error_feature_not_implemented, min = 0, max = 1, label = '$reason'}, #ref{name = error_forbidden, min = 0, max = 1, label = '$reason'}, #ref{name = error_gone, min = 0, max = 1, label = '$reason'}, #ref{name = error_internal_server_error, min = 0, max = 1, label = '$reason'}, #ref{name = error_item_not_found, min = 0, max = 1, label = '$reason'}, #ref{name = error_jid_malformed, min = 0, max = 1, label = '$reason'}, #ref{name = error_not_acceptable, min = 0, max = 1, label = '$reason'}, #ref{name = error_not_allowed, min = 0, max = 1, label = '$reason'}, #ref{name = error_not_authorized, min = 0, max = 1, label = '$reason'}, #ref{name = error_payment_required, min = 0, max = 1, label = '$reason'}, #ref{name = error_policy_violation, min = 0, max = 1, label = '$reason'}, #ref{name = error_recipient_unavailable, min = 0, max = 1, label = '$reason'}, #ref{name = error_redirect, min = 0, max = 1, label = '$reason'}, #ref{name = error_registration_required, min = 0, max = 1, label = '$reason'}, #ref{name = error_remote_server_not_found, min = 0, max = 1, label = '$reason'}, #ref{name = error_remote_server_timeout, min = 0, max = 1, label = '$reason'}, #ref{name = error_resource_constraint, min = 0, max = 1, label = '$reason'}, #ref{name = error_service_unavailable, min = 0, max = 1, label = '$reason'}, #ref{name = error_subscription_required, min = 0, max = 1, label = '$reason'}, #ref{name = error_undefined_condition, min = 0, max = 1, label = '$reason'}, #ref{name = error_unexpected_request, min = 0, max = 1, label = '$reason'}]}). -xml(bind_jid, #elem{name = <<"jid">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-bind">>, module = rfc6120, result = '$cdata', cdata = #cdata{dec = {jid, decode, []}, enc = {jid, encode, []}}}). -xml(bind_resource, #elem{name = <<"resource">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-bind">>, module = rfc6120, result = '$cdata', cdata = #cdata{dec = {check_resource, []}, enc = {check_resource, []}}}). -xml(bind, #elem{name = <<"bind">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-bind">>, module = rfc6120, result = {bind, '$jid', '$resource'}, refs = [#ref{name = bind_jid, label = '$jid', min = 0, max = 1}, #ref{name = bind_resource, min = 0, max = 1, default = <<"">>, label = '$resource'}]}). -xml(legacy_auth_username, #elem{name = <<"username">>, xmlns = <<"jabber:iq:auth">>, module = 'xep0078', result = '$cdata'}). -xml(legacy_auth_password, #elem{name = <<"password">>, xmlns = <<"jabber:iq:auth">>, module = 'xep0078', result = '$cdata'}). -xml(legacy_auth_digest, #elem{name = <<"digest">>, xmlns = <<"jabber:iq:auth">>, module = 'xep0078', result = '$cdata'}). -xml(legacy_auth_resource, #elem{name = <<"resource">>, xmlns = <<"jabber:iq:auth">>, module = 'xep0078', result = '$cdata'}). -xml(legacy_auth, #elem{name = <<"query">>, xmlns = <<"jabber:iq:auth">>, module = 'xep0078', result = {legacy_auth, '$username', '$password', '$digest', '$resource'}, refs = [#ref{name = legacy_auth_username, min = 0, max = 1, label = '$username'}, #ref{name = legacy_auth_password, min = 0, max = 1, label = '$password'}, #ref{name = legacy_auth_digest, min = 0, max = 1, label = '$digest'}, #ref{name = legacy_auth_resource, min = 0, max = 1, label = '$resource'}]}). -xml(legacy_auth_feature, #elem{name = <<"auth">>, xmlns = <<"http://jabber.org/features/iq-auth">>, module = 'xep0078', result = {legacy_auth_feature}}). -xml(sasl_auth, #elem{name = <<"auth">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, cdata = #cdata{label = '$text', dec = {base64, mime_decode, []}, enc = {base64, encode, []}}, result = {sasl_auth, '$mechanism', '$text'}, attrs = [#attr{name = <<"mechanism">>, required = true}]}). -xml(sasl_abort, #elem{name = <<"abort">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, result = {sasl_abort}}). -xml(sasl_challenge, #elem{name = <<"challenge">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, cdata = #cdata{label = '$text', dec = {base64, mime_decode, []}, enc = {base64, encode, []}}, result = {sasl_challenge, '$text'}}). -xml(sasl_response, #elem{name = <<"response">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, cdata = #cdata{label = '$text', dec = {base64, mime_decode, []}, enc = {base64, encode, []}}, result = {sasl_response, '$text'}}). -xml(sasl_success, #elem{name = <<"success">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, cdata = #cdata{label = '$text', dec = {base64, mime_decode, []}, enc = {base64, encode, []}}, result = {sasl_success, '$text'}}). -xml(sasl_failure_text, #elem{name = <<"text">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(sasl_failure_aborted, #elem{name = <<"aborted">>, result = 'aborted', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_account_disabled, #elem{name = <<"account-disabled">>, result = 'account-disabled', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_credentials_expired, #elem{name = <<"credentials-expired">>, result = 'credentials-expired', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_encryption_required, #elem{name = <<"encryption-required">>, result = 'encryption-required', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_incorrect_encoding, #elem{name = <<"incorrect-encoding">>, result = 'incorrect-encoding', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_invalid_authzid, #elem{name = <<"invalid-authzid">>, result = 'invalid-authzid', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_invalid_mechanism, #elem{name = <<"invalid-mechanism">>, result = 'invalid-mechanism', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_malformed_request, #elem{name = <<"malformed-request">>, result = 'malformed-request', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_mechanism_too_weak, #elem{name = <<"mechanism-too-weak">>, result = 'mechanism-too-weak', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_not_authorized, #elem{name = <<"not-authorized">>, result = 'not-authorized', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_bad_protocol, #elem{name = <<"bad-protocol">>, result = 'bad-protocol', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure_temporary_auth_failure, #elem{name = <<"temporary-auth-failure">>, result = 'temporary-auth-failure', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>}). -xml(sasl_failure, #elem{name = <<"failure">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, result = {sasl_failure, '$reason', '$text'}, refs = [#ref{name = sasl_failure_text, label = '$text'}, #ref{name = sasl_failure_aborted, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_account_disabled, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_credentials_expired, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_encryption_required, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_incorrect_encoding, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_invalid_authzid, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_invalid_mechanism, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_malformed_request, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_mechanism_too_weak, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_not_authorized, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_bad_protocol, min = 0, max = 1, label = '$reason'}, #ref{name = sasl_failure_temporary_auth_failure, min = 0, max = 1, label = '$reason'}]}). -xml(sasl_mechanism, #elem{name = <<"mechanism">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, result = '$cdata'}). -xml(sasl_mechanisms, #elem{name = <<"mechanisms">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-sasl">>, module = rfc6120, result = {sasl_mechanisms, '$list'}, refs = [#ref{name = sasl_mechanism, label = '$list'}]}). -xml(starttls_required, #elem{name = <<"required">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>, module = rfc6120, result = true}). -xml(starttls, #elem{name = <<"starttls">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>, module = rfc6120, result = {starttls, '$required'}, refs = [#ref{name = starttls_required, label = '$required', min = 0, max = 1, default = false}]}). -xml(starttls_proceed, #elem{name = <<"proceed">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>, module = rfc6120, result = {starttls_proceed}}). -xml(starttls_failure, #elem{name = <<"failure">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-tls">>, module = rfc6120, result = {starttls_failure}}). -xml(compress_failure_setup_failed, #elem{name = <<"setup-failed">>, xmlns = <<"http://jabber.org/protocol/compress">>, module = 'xep0138', result = 'setup-failed'}). -xml(compress_failure_processing_failed, #elem{name = <<"processing-failed">>, xmlns = <<"http://jabber.org/protocol/compress">>, module = 'xep0138', result = 'processing-failed'}). -xml(compress_failure_unsupported_method, #elem{name = <<"unsupported-method">>, xmlns = <<"http://jabber.org/protocol/compress">>, module = 'xep0138', result = 'unsupported-method'}). -xml(compress_failure, #elem{name = <<"failure">>, xmlns = <<"http://jabber.org/protocol/compress">>, module = 'xep0138', result = {compress_failure, '$reason'}, refs = [#ref{name = compress_failure_setup_failed, min = 0, max = 1, label = '$reason'}, #ref{name = compress_failure_processing_failed, min = 0, max = 1, label = '$reason'}, #ref{name = compress_failure_unsupported_method, min = 0, max = 1, label = '$reason'}]}). -xml(compress_method, #elem{name = <<"method">>, xmlns = <<"http://jabber.org/protocol/compress">>, module = 'xep0138', result = '$cdata'}). -xml(compress, #elem{name = <<"compress">>, xmlns = <<"http://jabber.org/protocol/compress">>, module = 'xep0138', result = {compress, '$methods'}, refs = [#ref{name = compress_method, label = '$methods'}]}). -xml(compressed, #elem{name = <<"compressed">>, xmlns = <<"http://jabber.org/protocol/compress">>, module = 'xep0138', result = {compressed}}). -xml(compression_method, #elem{name = <<"method">>, xmlns = <<"http://jabber.org/features/compress">>, module = 'xep0138', result = '$cdata'}). -xml(compression, #elem{name = <<"compression">>, xmlns = <<"http://jabber.org/features/compress">>, module = 'xep0138', result = {compression, '$methods'}, refs = [#ref{name = compression_method, label = '$methods'}]}). -xml(stream_features, #elem{name = <<"stream:features">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>], module = rfc6120, result = {stream_features, '$_els'}}). -xml(caps, #elem{name = <<"c">>, xmlns = <<"http://jabber.org/protocol/caps">>, module = 'xep0115', result = {caps, '$node', '$version', '$hash', '$exts'}, attrs = [#attr{name = <<"hash">>}, #attr{name = <<"node">>}, #attr{name = <<"ext">>, label = '$exts', default = [], dec = {re, split, ["\\h+"]}, enc = {join, [$ ]}}, #attr{name = <<"ver">>, label = '$version'}]}). -xml(feature_register, #elem{name = <<"register">>, xmlns = <<"http://jabber.org/features/iq-register">>, module = 'xep0077', result = {feature_register}}). -xml(register_registered, #elem{name = <<"registered">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = true}). -xml(register_remove, #elem{name = <<"remove">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = true}). -xml(register_instructions, #elem{name = <<"instructions">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_username, #elem{name = <<"username">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_nick, #elem{name = <<"nick">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_password, #elem{name = <<"password">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_name, #elem{name = <<"name">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_first, #elem{name = <<"first">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_last, #elem{name = <<"last">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_email, #elem{name = <<"email">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_address, #elem{name = <<"address">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_city, #elem{name = <<"city">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_state, #elem{name = <<"state">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_zip, #elem{name = <<"zip">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_phone, #elem{name = <<"phone">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_url, #elem{name = <<"url">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_date, #elem{name = <<"date">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_misc, #elem{name = <<"misc">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_text, #elem{name = <<"text">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register_key, #elem{name = <<"key">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = '$cdata'}). -xml(register, #elem{name = <<"query">>, xmlns = <<"jabber:iq:register">>, module = 'xep0077', result = {register, '$registered', '$remove', '$instructions', '$username', '$nick', '$password', '$name', '$first', '$last', '$email', '$address', '$city', '$state', '$zip', '$phone', '$url', '$date', '$misc', '$text', '$key', '$xdata', '$_els'}, refs = [#ref{name = xdata, min = 0, max = 1, label = '$xdata'}, #ref{name = register_registered, min = 0, max = 1, default = false, label = '$registered'}, #ref{name = register_remove, min = 0, max = 1, default = false, label = '$remove'}, #ref{name = register_instructions, min = 0, max = 1, label = '$instructions'}, #ref{name = register_username, min = 0, max = 1, label = '$username'}, #ref{name = register_nick, min = 0, max = 1, label = '$nick'}, #ref{name = register_password, min = 0, max = 1, label = '$password'}, #ref{name = register_name, min = 0, max = 1, label = '$name'}, #ref{name = register_first, min = 0, max = 1, label = '$first'}, #ref{name = register_last, min = 0, max = 1, label = '$last'}, #ref{name = register_email, min = 0, max = 1, label = '$email'}, #ref{name = register_address, min = 0, max = 1, label = '$address'}, #ref{name = register_city, min = 0, max = 1, label = '$city'}, #ref{name = register_state, min = 0, max = 1, label = '$state'}, #ref{name = register_zip, min = 0, max = 1, label = '$zip'}, #ref{name = register_phone, min = 0, max = 1, label = '$phone'}, #ref{name = register_url, min = 0, max = 1, label = '$url'}, #ref{name = register_date, min = 0, max = 1, label = '$date'}, #ref{name = register_misc, min = 0, max = 1, label = '$misc'}, #ref{name = register_text, min = 0, max = 1, label = '$text'}, #ref{name = register_key, min = 0, max = 1, label = '$key'}]}). -xml(session_optional, #elem{name = <<"optional">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-session">>, module = rfc3921, result = true}). -xml(session, #elem{name = <<"session">>, xmlns = <<"urn:ietf:params:xml:ns:xmpp-session">>, module = rfc3921, result = {xmpp_session, '$optional'}, refs = [#ref{name = session_optional, min = 0, max = 1, default = false, label = '$optional'}]}). -xml(ping, #elem{name = <<"ping">>, xmlns = <<"urn:xmpp:ping">>, module = 'xep0199', result = {ping}}). -xml(time_utc, #elem{name = <<"utc">>, xmlns = <<"urn:xmpp:time">>, module = 'xep0202', result = '$cdata', cdata = #cdata{dec = {dec_utc, []}, enc = {enc_utc, []}}}). -xml(time_tzo, #elem{name = <<"tzo">>, xmlns = <<"urn:xmpp:time">>, module = 'xep0202', result = '$cdata', cdata = #cdata{dec = {dec_tzo, []}, enc = {enc_tzo, []}}}). -xml(time, #elem{name = <<"time">>, xmlns = <<"urn:xmpp:time">>, module = 'xep0202', result = {time, '$tzo', '$utc'}, refs = [#ref{name = time_tzo, label = '$tzo', min = 0, max = 1}, #ref{name = time_utc, label = '$utc', min = 0, max = 1}]}). -xml(stream_error_text, #elem{name = <<"text">>, result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>, module = rfc6120, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(stream_error_bad_format, #elem{name = <<"bad-format">>, result = 'bad-format', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_bad_namespace_prefix, #elem{name = <<"bad-namespace-prefix">>, result = 'bad-namespace-prefix', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_conflict, #elem{name = <<"conflict">>, result = 'conflict', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_connection_timeout, #elem{name = <<"connection-timeout">>, result = 'connection-timeout', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_host_gone, #elem{name = <<"host-gone">>, result = 'host-gone', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_host_unknown, #elem{name = <<"host-unknown">>, result = 'host-unknown', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_improper_addressing, #elem{name = <<"improper-addressing">>, result = 'improper-addressing', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_internal_server_error, #elem{name = <<"internal-server-error">>, result = 'internal-server-error', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_invalid_from, #elem{name = <<"invalid-from">>, result = 'invalid-from', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_invalid_id, #elem{name = <<"invalid-id">>, result = 'invalid-id', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_invalid_namespace, #elem{name = <<"invalid-namespace">>, result = 'invalid-namespace', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_invalid_xml, #elem{name = <<"invalid-xml">>, result = 'invalid-xml', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_not_authorized, #elem{name = <<"not-authorized">>, result = 'not-authorized', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_not_well_formed, #elem{name = <<"not-well-formed">>, result = 'not-well-formed', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_policy_violation, #elem{name = <<"policy-violation">>, result = 'policy-violation', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_remote_connection_failed, #elem{name = <<"remote-connection-failed">>, result = 'remote-connection-failed', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_reset, #elem{name = <<"reset">>, result = 'reset', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_resource_constraint, #elem{name = <<"resource-constraint">>, result = 'resource-constraint', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_restricted_xml, #elem{name = <<"restricted-xml">>, result = 'restricted-xml', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_see_other_host, #elem{name = <<"see-other-host">>, cdata = #cdata{required = true, label = '$host', dec = {dec_host_port, []}, enc = {enc_host_port, []}}, result = {'see-other-host', '$host'}, module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_system_shutdown, #elem{name = <<"system-shutdown">>, result = 'system-shutdown', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_undefined_condition, #elem{name = <<"undefined-condition">>, result = 'undefined-condition', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_unsupported_encoding, #elem{name = <<"unsupported-encoding">>, result = 'unsupported-encoding', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_unsupported_feature, #elem{name = <<"unsupported-feature">>, result = 'unsupported-feature', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_unsupported_stanza_type, #elem{name = <<"unsupported-stanza-type">>, result = 'unsupported-stanza-type', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error_unsupported_version, #elem{name = <<"unsupported-version">>, result = 'unsupported-version', module = rfc6120, xmlns = <<"urn:ietf:params:xml:ns:xmpp-streams">>}). -xml(stream_error, #elem{name = <<"stream:error">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {stream_error, '$reason', '$text'}, refs = [#ref{name = stream_error_text, label = '$text'}, #ref{name = stream_error_bad_format, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_bad_namespace_prefix, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_conflict, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_connection_timeout, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_host_gone, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_host_unknown, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_improper_addressing, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_internal_server_error, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_invalid_from, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_invalid_id, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_invalid_namespace, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_invalid_xml, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_not_authorized, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_not_well_formed, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_policy_violation, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_remote_connection_failed, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_reset, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_resource_constraint, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_restricted_xml, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_see_other_host, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_system_shutdown, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_undefined_condition, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_unsupported_encoding, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_unsupported_feature, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_unsupported_stanza_type, min = 0, max = 1, label = '$reason'}, #ref{name = stream_error_unsupported_version, min = 0, max = 1, label = '$reason'} ]}). -xml(vcard_HOME, #elem{name = <<"HOME">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_WORK, #elem{name = <<"WORK">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_VOICE, #elem{name = <<"VOICE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_FAX, #elem{name = <<"FAX">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_PAGER, #elem{name = <<"PAGER">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_MSG, #elem{name = <<"MSG">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_CELL, #elem{name = <<"CELL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_VIDEO, #elem{name = <<"VIDEO">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_BBS, #elem{name = <<"BBS">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_MODEM, #elem{name = <<"MODEM">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_ISDN, #elem{name = <<"ISDN">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_PCS, #elem{name = <<"PCS">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_POSTAL, #elem{name = <<"POSTAL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_PARCEL, #elem{name = <<"PARCEL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_DOM, #elem{name = <<"DOM">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_INTL, #elem{name = <<"INTL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_PREF, #elem{name = <<"PREF">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_INTERNET, #elem{name = <<"INTERNET">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_X400, #elem{name = <<"X400">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = true}). -xml(vcard_FAMILY, #elem{name = <<"FAMILY">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_GIVEN, #elem{name = <<"GIVEN">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_MIDDLE, #elem{name = <<"MIDDLE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_PREFIX, #elem{name = <<"PREFIX">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_SUFFIX, #elem{name = <<"SUFFIX">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_POBOX, #elem{name = <<"POBOX">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_EXTADD, #elem{name = <<"EXTADD">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_STREET, #elem{name = <<"STREET">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_LOCALITY, #elem{name = <<"LOCALITY">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_REGION, #elem{name = <<"REGION">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_PCODE, #elem{name = <<"PCODE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_CTRY, #elem{name = <<"CTRY">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_LINE, #elem{name = <<"LINE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_NUMBER, #elem{name = <<"NUMBER">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_USERID, #elem{name = <<"USERID">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_LAT, #elem{name = <<"LAT">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_LON, #elem{name = <<"LON">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_ORGNAME, #elem{name = <<"ORGNAME">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_ORGUNIT, #elem{name = <<"ORGUNIT">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_PHONETIC, #elem{name = <<"PHONETIC">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_CRED, #elem{name = <<"CRED">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_VERSION, #elem{name = <<"VERSION">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_FN, #elem{name = <<"FN">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_NICKNAME, #elem{name = <<"NICKNAME">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_BDAY, #elem{name = <<"BDAY">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_JABBERID, #elem{name = <<"JABBERID">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_MAILER, #elem{name = <<"MAILER">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_TZ, #elem{name = <<"TZ">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_TITLE, #elem{name = <<"TITLE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_ROLE, #elem{name = <<"ROLE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_KEYWORD, #elem{name = <<"KEYWORD">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_NOTE, #elem{name = <<"NOTE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_PRODID, #elem{name = <<"PRODID">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_REV, #elem{name = <<"REV">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_SORT_STRING, #elem{name = <<"SORT-STRING">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_UID, #elem{name = <<"UID">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_URL, #elem{name = <<"URL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_DESC, #elem{name = <<"DESC">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_TYPE, #elem{name = <<"TYPE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_EXTVAL, #elem{name = <<"EXTVAL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$cdata'}). -xml(vcard_PUBLIC, #elem{name = <<"PUBLIC">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = public}). -xml(vcard_PRIVATE, #elem{name = <<"PRIVATE">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = private}). -xml(vcard_CONFIDENTIAL, #elem{name = <<"CONFIDENTIAL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = confidential}). -xml(vcard_N, #elem{name = <<"N">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_name, '$family', '$given', '$middle', '$prefix', '$suffix'}, refs = [#ref{name = vcard_FAMILY, min = 0, max = 1, label = '$family'}, #ref{name = vcard_GIVEN, min = 0, max = 1, label = '$given'}, #ref{name = vcard_MIDDLE, min = 0, max = 1, label = '$middle'}, #ref{name = vcard_PREFIX, min = 0, max = 1, label = '$prefix'}, #ref{name = vcard_SUFFIX, min = 0, max = 1, label = '$suffix'}]}). -xml(vcard_ADR, #elem{name = <<"ADR">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_adr, '$home', '$work', '$postal', '$parcel', '$dom', '$intl', '$pref', '$pobox', '$extadd', '$street', '$locality', '$region', '$pcode', '$ctry'}, refs = [#ref{name = vcard_HOME, default = false, min = 0, max = 1, label = '$home'}, #ref{name = vcard_WORK, default = false, min = 0, max = 1, label = '$work'}, #ref{name = vcard_POSTAL, default = false, min = 0, max = 1, label = '$postal'}, #ref{name = vcard_PARCEL, default = false, min = 0, max = 1, label = '$parcel'}, #ref{name = vcard_DOM, default = false, min = 0, max = 1, label = '$dom'}, #ref{name = vcard_INTL, default = false, min = 0, max = 1, label = '$intl'}, #ref{name = vcard_PREF, default = false, min = 0, max = 1, label = '$pref'}, #ref{name = vcard_POBOX, min = 0, max = 1, label = '$pobox'}, #ref{name = vcard_EXTADD, min = 0, max = 1, label = '$extadd'}, #ref{name = vcard_STREET, min = 0, max = 1, label = '$street'}, #ref{name = vcard_LOCALITY, min = 0, max = 1, label = '$locality'}, #ref{name = vcard_REGION, min = 0, max = 1, label = '$region'}, #ref{name = vcard_PCODE, min = 0, max = 1, label = '$pcode'}, #ref{name = vcard_CTRY, min = 0, max = 1, label = '$ctry'}]}). -xml(vcard_LABEL, #elem{name = <<"LABEL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_label, '$home', '$work', '$postal', '$parcel', '$dom', '$intl', '$pref', '$line'}, refs = [#ref{name = vcard_HOME, default = false, min = 0, max = 1, label = '$home'}, #ref{name = vcard_WORK, default = false, min = 0, max = 1, label = '$work'}, #ref{name = vcard_POSTAL, default = false, min = 0, max = 1, label = '$postal'}, #ref{name = vcard_PARCEL, default = false, min = 0, max = 1, label = '$parcel'}, #ref{name = vcard_DOM, default = false, min = 0, max = 1, label = '$dom'}, #ref{name = vcard_INTL, default = false, min = 0, max = 1, label = '$intl'}, #ref{name = vcard_PREF, default = false, min = 0, max = 1, label = '$pref'}, #ref{name = vcard_LINE, label = '$line'}]}). -xml(vcard_TEL, #elem{name = <<"TEL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_tel, '$home', '$work', '$voice', '$fax', '$pager', '$msg', '$cell', '$video', '$bbs', '$modem', '$isdn', '$pcs', '$pref', '$number'}, refs = [#ref{name = vcard_HOME, default = false, min = 0, max = 1, label = '$home'}, #ref{name = vcard_WORK, default = false, min = 0, max = 1, label = '$work'}, #ref{name = vcard_VOICE, default = false, min = 0, max = 1, label = '$voice'}, #ref{name = vcard_FAX, default = false, min = 0, max = 1, label = '$fax'}, #ref{name = vcard_PAGER, default = false, min = 0, max = 1, label = '$pager'}, #ref{name = vcard_MSG, default = false, min = 0, max = 1, label = '$msg'}, #ref{name = vcard_CELL, default = false, min = 0, max = 1, label = '$cell'}, #ref{name = vcard_VIDEO, default = false, min = 0, max = 1, label = '$video'}, #ref{name = vcard_BBS, default = false, min = 0, max = 1, label = '$bbs'}, #ref{name = vcard_MODEM, default = false, min = 0, max = 1, label = '$modem'}, #ref{name = vcard_ISDN, default = false, min = 0, max = 1, label = '$isdn'}, #ref{name = vcard_PCS, default = false, min = 0, max = 1, label = '$pcs'}, #ref{name = vcard_PREF, default = false, min = 0, max = 1, label = '$pref'}, #ref{name = vcard_NUMBER, min = 0, max = 1, label = '$number'}]}). -xml(vcard_EMAIL, #elem{name = <<"EMAIL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_email, '$home', '$work', '$internet', '$pref', '$x400', '$userid'}, refs = [#ref{name = vcard_HOME, default = false, min = 0, max = 1, label = '$home'}, #ref{name = vcard_WORK, default = false, min = 0, max = 1, label = '$work'}, #ref{name = vcard_INTERNET, default = false, min = 0, max = 1, label = '$internet'}, #ref{name = vcard_PREF, default = false, min = 0, max = 1, label = '$pref'}, #ref{name = vcard_X400, default = false, min = 0, max = 1, label = '$x400'}, #ref{name = vcard_USERID, min = 0, max = 1, label = '$userid'}]}). -xml(vcard_GEO, #elem{name = <<"GEO">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_geo, '$lat', '$lon'}, refs = [#ref{name = vcard_LAT, min = 0, max = 1, label = '$lat'}, #ref{name = vcard_LON, min = 0, max = 1, label = '$lon'}]}). -xml(vcard_BINVAL, #elem{name = <<"BINVAL">>, xmlns = <<"vcard-temp">>, module = 'xep0054', cdata = #cdata{dec = {base64, decode, []}, enc = {base64, encode, []}}, result = '$cdata'}). -xml(vcard_LOGO, #elem{name = <<"LOGO">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_logo, '$type', '$binval', '$extval'}, refs = [#ref{name = vcard_TYPE, min = 0, max = 1, label = '$type'}, #ref{name = vcard_BINVAL, min = 0, max = 1, label = '$binval'}, #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'}]}). -xml(vcard_PHOTO, #elem{name = <<"PHOTO">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_photo, '$type', '$binval', '$extval'}, refs = [#ref{name = vcard_TYPE, min = 0, max = 1, label = '$type'}, #ref{name = vcard_BINVAL, min = 0, max = 1, label = '$binval'}, #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'}]}). -xml(vcard_ORG, #elem{name = <<"ORG">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_org, '$name', '$units'}, refs = [#ref{name = vcard_ORGNAME, label = '$name', min = 0, max = 1}, #ref{name = vcard_ORGUNIT, label = '$units'}]}). -xml(vcard_SOUND, #elem{name = <<"SOUND">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_sound, '$phonetic', '$binval', '$extval'}, refs = [#ref{name = vcard_BINVAL, min = 0, max = 1, label = '$binval'}, #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'}, #ref{name = vcard_PHONETIC, min = 0, max = 1, label = '$phonetic'}]}). -xml(vcard_KEY, #elem{name = <<"KEY">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_key, '$type', '$cred'}, refs = [#ref{name = vcard_TYPE, min = 0, max = 1, label = '$type'}, #ref{name = vcard_CRED, min = 0, max = 1, label = '$cred'}]}). -xml(vcard_CATEGORIES, #elem{name = <<"CATEGORIES">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$keywords', refs = [#ref{name = vcard_KEYWORD, label = '$keywords'}]}). -xml(vcard_CLASS, #elem{name = <<"CLASS">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = '$class', refs = [#ref{name = vcard_PUBLIC, min = 0, max = 1, label = '$class'}, #ref{name = vcard_PRIVATE, min = 0, max = 1, label = '$class'}, #ref{name = vcard_CONFIDENTIAL, min = 0, max = 1, label = '$class'}]}). %% {vcard_AGENT, %% #elem{name = <<"AGENT">>, %% xmlns = <<"vcard-temp">>, %% module = 'xep0054', %% result = {vcard_agent, '$vcard', '$extval'}, %% refs = [#ref{name = vcard, min = 0, max = 1, label = '$vcard'}, %% #ref{name = vcard_EXTVAL, min = 0, max = 1, label = '$extval'}]}). -xml(vcard_temp, #elem{name = <<"vCard">>, xmlns = <<"vcard-temp">>, module = 'xep0054', result = {vcard_temp, '$version', '$fn', '$n', '$nickname', '$photo', '$bday', '$adr', '$label', '$tel', '$email', '$jabberid', '$mailer', '$tz', '$geo', '$title', '$role', '$logo', '$org', '$categories', '$note', '$prodid', %% '$agent', '$rev', '$sort_string', '$sound', '$uid', '$url', '$class', '$key', '$desc'}, refs = [#ref{name = vcard_N, min = 0, max = 1, label = '$n'}, #ref{name = vcard_ADR, label = '$adr'}, #ref{name = vcard_LABEL, label = '$label'}, #ref{name = vcard_TEL, label = '$tel'}, #ref{name = vcard_EMAIL, label = '$email'}, #ref{name = vcard_GEO, min = 0, max = 1, label = '$geo'}, #ref{name = vcard_LOGO, min = 0, max = 1, label = '$logo'}, #ref{name = vcard_PHOTO, min = 0, max = 1, label = '$photo'}, #ref{name = vcard_ORG, min = 0, max = 1, label = '$org'}, #ref{name = vcard_SOUND, min = 0, max = 1, label = '$sound'}, #ref{name = vcard_KEY, min = 0, max = 1, label = '$key'}, #ref{name = vcard_VERSION, min = 0, max = 1, label = '$version'}, #ref{name = vcard_FN, min = 0, max = 1, label = '$fn'}, #ref{name = vcard_NICKNAME, min = 0, max = 1, label = '$nickname'}, #ref{name = vcard_BDAY, min = 0, max = 1, label = '$bday'}, #ref{name = vcard_JABBERID, min = 0, max = 1, label = '$jabberid'}, #ref{name = vcard_MAILER, min = 0, max = 1, label = '$mailer'}, #ref{name = vcard_TZ, min = 0, max = 1, label = '$tz'}, #ref{name = vcard_TITLE, min = 0, max = 1, label = '$title'}, #ref{name = vcard_ROLE, min = 0, max = 1, label = '$role'}, #ref{name = vcard_NOTE, min = 0, max = 1, label = '$note'}, #ref{name = vcard_PRODID, min = 0, max = 1, label = '$prodid'}, #ref{name = vcard_REV, min = 0, max = 1, label = '$rev'}, %%#ref{name = vcard_AGENT, min = 0, max = 1, label = '$agent'}, #ref{name = vcard_SORT_STRING, min = 0, max = 1, label = '$sort_string'}, #ref{name = vcard_UID, min = 0, max = 1, label = '$uid'}, #ref{name = vcard_URL, min = 0, max = 1, label = '$url'}, #ref{name = vcard_DESC, min = 0, max = 1, label = '$desc'}, #ref{name = vcard_CATEGORIES, default = [], min = 0, max = 1, label = '$categories'}, #ref{name = vcard_CLASS, min = 0, max = 1, label = '$class'}]}). -xml(vcard_xupdate_photo, #elem{name = <<"photo">>, xmlns = <<"vcard-temp:x:update">>, module = 'xep0153', result = '$cdata'}). -xml(vcard_xupdate, #elem{name = <<"x">>, xmlns = <<"vcard-temp:x:update">>, module = 'xep0153', result = {vcard_xupdate, '$hash'}, refs = [#ref{name = vcard_xupdate_photo, min = 0, max = 1, label = '$hash'}]}). -xml(xdata_field_required, #elem{name = <<"required">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = true}). -xml(xdata_field_desc, #elem{name = <<"desc">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = '$cdata'}). -xml(xdata_field_value, #elem{name = <<"value">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = '$cdata'}). -xml(xdata_field_option, #elem{name = <<"option">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = {xdata_option, '$label', '$value'}, attrs = [#attr{name = <<"label">>}], refs = [#ref{name = xdata_field_value, label = '$value', min = 1, max = 1}]}). -xml(xdata_field, #elem{name = <<"field">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = {xdata_field, '$label', '$type', '$var', '$required', '$desc', '$values', '$options', '$_els'}, attrs = [#attr{name = <<"label">>}, #attr{name = <<"type">>, enc = {enc_enum, []}, dec = {dec_enum, [['boolean', 'fixed', 'hidden', 'jid-multi', 'jid-single', 'list-multi', 'list-single', 'text-multi', 'text-private', 'text-single']]}}, #attr{name = <<"var">>}], refs = [#ref{name = xdata_field_required, label = '$required', default = false, min = 0, max = 1}, #ref{name = xdata_field_desc, default = <<"">>, label = '$desc', min = 0, max = 1}, #ref{name = xdata_field_value, label = '$values'}, #ref{name = xdata_field_option, label = '$options'}]}). -xml(xdata_instructions, #elem{name = <<"instructions">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = '$cdata'}). -xml(xdata_title, #elem{name = <<"title">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = '$cdata'}). -xml(xdata_reported, #elem{name = <<"reported">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = '$fields', refs = [#ref{name = xdata_field, label = '$fields'}]}). -xml(xdata_item, #elem{name = <<"item">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = '$fields', refs = [#ref{name = xdata_field, label = '$fields'}]}). -xml(xdata, #elem{name = <<"x">>, xmlns = <<"jabber:x:data">>, module = 'xep0004', result = {xdata, '$type', '$instructions', '$title', '$reported', '$items', '$fields'}, attrs = [#attr{name = <<"type">>, required = true, dec = {dec_enum, [[cancel, form, result, submit]]}, enc = {enc_enum, []}}], refs = [#ref{name = xdata_instructions, label = '$instructions'}, #ref{name = xdata_title, label = '$title', min = 0, max = 1}, #ref{name = xdata_reported, label = '$reported', min = 0, max = 1}, #ref{name = xdata_item, label = '$items'}, #ref{name = xdata_field, label = '$fields'}]}). -xml(pubsub_subscription, #elem{name = <<"subscription">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], module = 'xep0060', result = {ps_subscription, '$xmlns', '$jid', '$type', '$node', '$subid', '$expiry'}, attrs = [#attr{name = <<"xmlns">>}, #attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"node">>}, #attr{name = <<"subid">>}, #attr{name = <<"subscription">>, label = '$type', dec = {dec_enum, [[none, pending, subscribed, unconfigured]]}, enc = {enc_enum, []}}, #attr{name = <<"expiry">>, dec = {dec_utc, []}, enc = {enc_utc, []}}]}). -record(ps_affiliation, {xmlns = <<>> :: binary(), node = <<>> :: binary(), type :: member | none | outcast | owner | publisher | publish_only, jid :: undefined | jid:jid()}). -type ps_affiliation() :: #ps_affiliation{}. -xml(pubsub_affiliation, #elem{name = <<"affiliation">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {ps_affiliation, '$xmlns', '$node', '$type', '$_'}, attrs = [#attr{name = <<"node">>, required = true}, #attr{name = <<"xmlns">>}, #attr{name = <<"affiliation">>, label = '$type', required = true, dec = {dec_ps_aff, []}, enc = {enc_ps_aff, []}}]}). -xml(pubsub_owner_affiliation, #elem{name = <<"affiliation">>, xmlns = <<"http://jabber.org/protocol/pubsub#owner">>, module = 'xep0060', result = {ps_affiliation, '$xmlns', '$_', '$type', '$jid'}, attrs = [#attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"xmlns">>}, #attr{name = <<"affiliation">>, label = '$type', required = true, dec = {dec_ps_aff, []}, enc = {enc_ps_aff, []}}]}). -xml(pubsub_event_configuration, #elem{name = <<"configuration">>, xmlns = <<"http://jabber.org/protocol/pubsub#event">>, module = 'xep0060', result = {'$node', '$xdata'}, attrs = [#attr{name = <<"node">>, required = true}], refs = [#ref{name = xdata, min = 0, max = 1}]}). -xml(pubsub_event_retract, #elem{name = <<"retract">>, xmlns = <<"http://jabber.org/protocol/pubsub#event">>, module = 'xep0060', result = '$id', attrs = [#attr{name = <<"id">>, required = true}]}). -xml(pubsub_item, #elem{name = <<"item">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#event">>], module = 'xep0060', ignore_els = true, result = {ps_item, '$xmlns', '$id', '$_els', '$node', '$publisher'}, attrs = [#attr{name = <<"id">>}, #attr{name = <<"xmlns">>}, #attr{name = <<"node">>}, #attr{name = <<"publisher">>}]}). -xml(pubsub_items, #elem{name = <<"items">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#event">>], module = 'xep0060', result = {ps_items, '$xmlns', '$node', '$items', '$max_items', '$subid', '$retract'}, attrs = [#attr{name = <<"xmlns">>}, #attr{name = <<"max_items">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"node">>, required = true}, #attr{name = <<"subid">>}], refs = [#ref{name = pubsub_event_retract, label = '$retract', min = 0, max = 1}, #ref{name = pubsub_item, label = '$items'}]}). -xml(pubsub_event, #elem{name = <<"event">>, xmlns = <<"http://jabber.org/protocol/pubsub#event">>, module = 'xep0060', result = {ps_event, '$items', '$purge', '$subscription', '$delete', '$create', '$configuration'}, refs = [#ref{name = pubsub_items, label = '$items', min = 0, max = 1}, #ref{name = pubsub_subscription, min = 0, max = 1, label = '$subscription'}, #ref{name = pubsub_purge, min = 0, max = 1, label = '$purge'}, #ref{name = pubsub_delete, min = 0, max = 1, label = '$delete'}, #ref{name = pubsub_create, min = 0, max = 1, label = '$create'}, #ref{name = pubsub_event_configuration, min = 0, max = 1, label = '$configuration'}]}). -xml(pubsub_subscriptions, #elem{name = <<"subscriptions">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>], module = 'xep0060', result = {'$node', '$subscriptions'}, attrs = [#attr{name = <<"node">>}], refs = [#ref{name = pubsub_subscription, label = '$subscriptions'}]}). -xml(pubsub_affiliations, #elem{name = <<"affiliations">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {'$node', '$affiliations'}, attrs = [#attr{name = <<"node">>}], refs = [#ref{name = pubsub_affiliation, label = '$affiliations'}]}). -xml(pubsub_owner_affiliations, #elem{name = <<"affiliations">>, xmlns = <<"http://jabber.org/protocol/pubsub#owner">>, module = 'xep0060', result = {'$node', '$affiliations'}, attrs = [#attr{name = <<"node">>}], refs = [#ref{name = pubsub_owner_affiliation, label = '$affiliations'}]}). -xml(pubsub_subscribe, #elem{name = <<"subscribe">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {ps_subscribe, '$node', '$jid'}, attrs = [#attr{name = <<"node">>}, #attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}]}). -xml(pubsub_unsubscribe, #elem{name = <<"unsubscribe">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {ps_unsubscribe, '$node', '$jid', '$subid'}, attrs = [#attr{name = <<"node">>}, #attr{name = <<"subid">>}, #attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}]}). -xml(pubsub_publish, #elem{name = <<"publish">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {ps_publish, '$node', '$items'}, attrs = [#attr{name = <<"node">>, required = true}], refs = [#ref{name = pubsub_item, label = '$items'}]}). -xml(pubsub_options, #elem{name = <<"options">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {ps_options, '$node', '$jid', '$subid', '$xdata'}, attrs = [#attr{name = <<"node">>}, #attr{name = <<"subid">>}, #attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = xdata, min = 0, max = 1, label = '$xdata'}]}). -xml(pubsub_retract, #elem{name = <<"retract">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {ps_retract, '$node', '$notify', '$items'}, attrs = [#attr{name = <<"node">>, required = true}, #attr{name = <<"notify">>, default = false, dec = {dec_bool, []}, enc = {enc_bool, []}}], refs = [#ref{name = pubsub_item, label = '$items'}]}). -xml(pubsub_create, #elem{name = <<"create">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#event">>], module = 'xep0060', result = '$node', attrs = [#attr{name = <<"node">>}]}). -xml(pubsub_configure, #elem{name = <<"configure">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>], module = 'xep0060', result = {'$node', '$xdata'}, attrs = [#attr{name = <<"node">>}], refs = [#ref{name = xdata, min = 0, max = 1}]}). -xml(pubsub_publish_options, #elem{name = <<"publish-options">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = '$xdata', refs = [#ref{name = xdata, min = 0, max = 1}]}). -xml(pubsub_default, #elem{name = <<"default">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>], module = 'xep0060', result = {'$node', '$xdata'}, attrs = [#attr{name = <<"node">>}], refs = [#ref{name = xdata, min = 0, max = 1}]}). -xml(pubsub_redirect, #elem{name = <<"redirect">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], module = 'xep0060', result = '$uri', attrs = [#attr{name = <<"uri">>, required = true}]}). -xml(pubsub_delete, #elem{name = <<"delete">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], module = 'xep0060', result = {'$node', '$uri'}, attrs = [#attr{name = <<"node">>, required = true}], refs = [#ref{name = pubsub_redirect, min = 0, max = 1, label = '$uri', default = <<>>}]}). -xml(pubsub_purge, #elem{name = <<"purge">>, xmlns = [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], module = 'xep0060', result = '$node', attrs = [#attr{name = <<"node">>, required = true}]}). -xml(pubsub, #elem{name = <<"pubsub">>, xmlns = <<"http://jabber.org/protocol/pubsub">>, module = 'xep0060', result = {pubsub, '$subscriptions', '$subscription', '$affiliations', '$publish', '$publish_options', '$subscribe', '$unsubscribe', '$options', '$items', '$retract', '$create', '$configure', '$default', '$delete', '$purge', '$rsm'}, refs = [#ref{name = pubsub_subscriptions, label = '$subscriptions', min = 0, max = 1}, #ref{name = pubsub_affiliations, label = '$affiliations', min = 0, max = 1}, #ref{name = pubsub_subscribe, label = '$subscribe', min = 0, max = 1}, #ref{name = pubsub_unsubscribe, label = '$unsubscribe', min = 0, max = 1}, #ref{name = pubsub_options, label = '$options', min = 0, max = 1}, #ref{name = pubsub_items, label = '$items', min = 0, max = 1}, #ref{name = pubsub_retract, label = '$retract', min = 0, max = 1}, #ref{name = pubsub_create, label = '$create', min = 0, max = 1}, #ref{name = pubsub_configure, label = '$configure', min = 0, max = 1}, #ref{name = pubsub_publish_options, min = 0, max = 1, label = '$publish_options'}, #ref{name = pubsub_default, label = '$default', min = 0, max = 1}, #ref{name = pubsub_delete, label = '$delete', min = 0, max = 1}, #ref{name = pubsub_purge, label = '$purge', min = 0, max = 1}, #ref{name = pubsub_subscription, label = '$subscription', min = 0, max = 1}, #ref{name = rsm_set, min = 0, max = 1, label = '$rsm'}, #ref{name = pubsub_publish, label = '$publish', min = 0, max = 1}]}). -xml(pubsub_owner, #elem{name = <<"pubsub">>, xmlns = <<"http://jabber.org/protocol/pubsub#owner">>, module = 'xep0060', result = {pubsub_owner, '$affiliations', '$configure', '$default', '$delete', '$purge', '$subscriptions'}, refs = [#ref{name = pubsub_owner_affiliations, label = '$affiliations', min = 0, max = 1}, #ref{name = pubsub_configure, label = '$configure', min = 0, max = 1}, #ref{name = pubsub_default, label = '$default', min = 0, max = 1}, #ref{name = pubsub_delete, label = '$delete', min = 0, max = 1}, #ref{name = pubsub_purge, label = '$purge', min = 0, max = 1}, #ref{name = pubsub_subscriptions, label = '$subscriptions', min = 0, max = 1}]}). -type ps_error_type() :: 'closed-node' | 'configuration-required' | 'invalid-jid' | 'invalid-options' | 'invalid-payload' | 'invalid-subid' | 'item-forbidden' | 'item-required' | 'jid-required' | 'max-items-exceeded' | 'max-nodes-exceeded' | 'nodeid-required' | 'not-in-roster-group' | 'not-subscribed' | 'payload-too-big' | 'payload-required' | 'pending-subscription' | 'precondition-not-met' | 'presence-subscription-required' | 'subid-required' | 'too-many-subscriptions' | 'unsupported' | 'unsupported-access-model'. -type ps_feature() :: 'access-authorize' | 'access-open' | 'access-presence' | 'access-roster' | 'access-whitelist' | 'auto-create' | 'auto-subscribe' | 'collections' | 'config-node' | 'create-and-configure' | 'create-nodes' | 'delete-items' | 'delete-nodes' | 'filtered-notifications' | 'get-pending' | 'instant-nodes' | 'item-ids' | 'last-published' | 'leased-subscription' | 'manage-subscriptions' | 'member-affiliation' | 'meta-data' | 'modify-affiliations' | 'multi-collection' | 'multi-subscribe' | 'outcast-affiliation' | 'persistent-items' | 'presence-notifications' | 'presence-subscribe' | 'publish' | 'publish-options' | 'publish-only-affiliation' | 'publisher-affiliation' | 'purge-nodes' | 'retract-items' | 'retrieve-affiliations' | 'retrieve-default' | 'retrieve-items' | 'retrieve-subscriptions' | 'subscribe' | 'subscription-options' | 'subscription-notifications' | 'multi-items' | undefined. -record(ps_error, {type :: ps_error_type(), feature :: ps_feature()}). -type ps_error() :: #ps_error{}. -xml(pubsub_error_closed_node, #elem{name = <<"closed-node">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'closed-node', '$_'}}). -xml(pubsub_error_configuration_required, #elem{name = <<"configuration-required">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'configuration-required', '$_'}}). -xml(pubsub_error_invalid_jid, #elem{name = <<"invalid-jid">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'invalid-jid', '$_'}}). -xml(pubsub_error_invalid_options, #elem{name = <<"invalid-options">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'invalid-options', '$_'}}). -xml(pubsub_error_invalid_payload, #elem{name = <<"invalid-payload">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'invalid-payload', '$_'}}). -xml(pubsub_error_invalid_subid, #elem{name = <<"invalid-subid">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'invalid-subid', '$_'}}). -xml(pubsub_error_item_forbidden, #elem{name = <<"item-forbidden">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'item-forbidden', '$_'}}). -xml(pubsub_error_item_required, #elem{name = <<"item-required">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'item-required', '$_'}}). -xml(pubsub_error_jid_required, #elem{name = <<"jid-required">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'jid-required', '$_'}}). -xml(pubsub_error_max_items_exceeded, #elem{name = <<"max-items-exceeded">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'max-items-exceeded', '$_'}}). -xml(pubsub_error_max_nodes_exceeded, #elem{name = <<"max-nodes-exceeded">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'max-nodes-exceeded', '$_'}}). -xml(pubsub_error_nodeid_required, #elem{name = <<"nodeid-required">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'nodeid-required', '$_'}}). -xml(pubsub_error_not_in_roster_group, #elem{name = <<"not-in-roster-group">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'not-in-roster-group', '$_'}}). -xml(pubsub_error_not_subscribed, #elem{name = <<"not-subscribed">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'not-subscribed', '$_'}}). -xml(pubsub_error_payload_too_big, #elem{name = <<"payload-too-big">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'payload-too-big', '$_'}}). -xml(pubsub_error_payload_required, #elem{name = <<"payload-required">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'payload-required', '$_'}}). -xml(pubsub_error_pending_subscription, #elem{name = <<"pending-subscription">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'pending-subscription', '$_'}}). -xml(pubsub_error_precondition_not_met, #elem{name = <<"precondition-not-met">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'precondition-not-met', '$_'}}). -xml(pubsub_error_presence_subscription_required, #elem{name = <<"presence-subscription-required">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'presence-subscription-required', '$_'}}). -xml(pubsub_error_subid_required, #elem{name = <<"subid-required">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'subid-required', '$_'}}). -xml(pubsub_error_too_many_subscriptions, #elem{name = <<"too-many-subscriptions">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'too-many-subscriptions', '$_'}}). -xml(pubsub_error_unsupported, #elem{name = <<"unsupported">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'unsupported', '$feature'}, attrs = [#attr{name = <<"feature">>, required = true, dec = {dec_enum, [['access-authorize', 'access-open', 'access-presence', 'access-roster', 'access-whitelist', 'auto-create', 'auto-subscribe', 'collections', 'config-node', 'create-and-configure', 'create-nodes', 'delete-items', 'delete-nodes', 'filtered-notifications', 'get-pending', 'instant-nodes', 'item-ids', 'last-published', 'leased-subscription', 'manage-subscriptions', 'member-affiliation', 'meta-data', 'modify-affiliations', 'multi-collection', 'multi-items', 'multi-subscribe', 'outcast-affiliation', 'persistent-items', 'presence-notifications', 'presence-subscribe', 'publish', 'publish-options', 'publish-only-affiliation', 'publisher-affiliation', 'purge-nodes', 'retract-items', 'retrieve-affiliations', 'retrieve-default', 'retrieve-items', 'retrieve-subscriptions', 'subscribe', 'subscription-options', 'subscription-notifications']]}, enc = {enc_enum, []}}]}). -xml(pubsub_error_unsupported_access_model, #elem{name = <<"unsupported-access-model">>, xmlns = <<"http://jabber.org/protocol/pubsub#errors">>, module = 'xep0060', result = {ps_error, 'unsupported-access-model', '$_'}}). -xml(shim_header, #elem{name = <<"header">>, xmlns = <<"http://jabber.org/protocol/shim">>, module = 'xep0131', result = {'$name', '$cdata'}, attrs = [#attr{name = <<"name">>, required = true}]}). -xml(shim_headers, #elem{name = <<"headers">>, xmlns = <<"http://jabber.org/protocol/shim">>, module = 'xep0131', result = {shim, '$headers'}, refs = [#ref{name = shim_header, label = '$headers'}]}). -record(chatstate, {type :: active | composing | gone | inactive | paused}). -type chatstate() :: #chatstate{}. -xml(chatstate_active, #elem{name = <<"active">>, xmlns = <<"http://jabber.org/protocol/chatstates">>, module = 'xep0085', result = {chatstate, active}}). -xml(chatstate_composing, #elem{name = <<"composing">>, xmlns = <<"http://jabber.org/protocol/chatstates">>, module = 'xep0085', result = {chatstate, composing}}). -xml(chatstate_gone, #elem{name = <<"gone">>, xmlns = <<"http://jabber.org/protocol/chatstates">>, module = 'xep0085', result = {chatstate, gone}}). -xml(chatstate_inactive, #elem{name = <<"inactive">>, xmlns = <<"http://jabber.org/protocol/chatstates">>, module = 'xep0085', result = {chatstate, inactive}}). -xml(chatstate_paused, #elem{name = <<"paused">>, xmlns = <<"http://jabber.org/protocol/chatstates">>, module = 'xep0085', result = {chatstate, paused}}). -xml(delay, #elem{name = <<"delay">>, xmlns = <<"urn:xmpp:delay">>, module = 'xep0203', result = {delay, '$stamp', '$from', '$desc'}, cdata = #cdata{label = '$desc', default = <<"">>}, attrs = [#attr{name = <<"stamp">>, required = true, dec = {dec_utc, []}, enc = {enc_utc, []}}, #attr{name = <<"from">>, dec = {jid, decode, []}, enc = {jid, encode, []}}]}). -xml(bytestreams_streamhost, #elem{name = <<"streamhost">>, xmlns = <<"http://jabber.org/protocol/bytestreams">>, module = 'xep0065', result = {streamhost, '$jid', '$host', '$port'}, attrs = [#attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"host">>, required = true}, #attr{name = <<"port">>, default = 1080, dec = {dec_int, [0, 65535]}, enc = {enc_int, []}}]}). -xml(bytestreams_streamhost_used, #elem{name = <<"streamhost-used">>, xmlns = <<"http://jabber.org/protocol/bytestreams">>, module = 'xep0065', result = '$jid', attrs = [#attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}]}). -xml(bytestreams_activate, #elem{name = <<"activate">>, xmlns = <<"http://jabber.org/protocol/bytestreams">>, module = 'xep0065', cdata = #cdata{enc = {jid, encode, []}, dec = {jid, decode, []}}, result = '$cdata'}). -xml(bytestreams, #elem{name = <<"query">>, xmlns = <<"http://jabber.org/protocol/bytestreams">>, module = 'xep0065', result = {bytestreams, '$hosts', '$used', '$activate', '$dstaddr', '$mode', '$sid'}, attrs = [#attr{name = <<"dstaddr">>}, #attr{name = <<"sid">>}, #attr{name = <<"mode">>, default = tcp, dec = {dec_enum, [[tcp, udp]]}, enc = {enc_enum, []}}], refs = [#ref{name = bytestreams_streamhost, label = '$hosts'}, #ref{name = bytestreams_streamhost_used, min = 0, max = 1, label = '$used'}, #ref{name = bytestreams_activate, min = 0, max = 1, label = '$activate'}]}). -xml(muc_history, #elem{name = <<"history">>, xmlns = <<"http://jabber.org/protocol/muc">>, module = 'xep0045', result = {muc_history, '$maxchars', '$maxstanzas', '$seconds', '$since'}, attrs = [#attr{name = <<"maxchars">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"maxstanzas">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"seconds">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"since">>, dec = {dec_utc, []}, enc = {enc_utc, []}}]}). -xml(muc_reason, #elem{name = <<"reason">>, xmlns = [<<"http://jabber.org/protocol/muc#user">>, <<"http://jabber.org/protocol/muc#admin">>, <<"http://jabber.org/protocol/muc#owner">>], module = 'xep0045', result = '$cdata'}). -xml(muc_user_decline, #elem{name = <<"decline">>, xmlns = <<"http://jabber.org/protocol/muc#user">>, module = 'xep0045', result = {muc_decline, '$reason', '$from', '$to'}, attrs = [#attr{name = <<"to">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"from">>, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = muc_reason, min = 0, default = <<"">>, max = 1, label = '$reason'}]}). -xml(muc_destroy, #elem{name = <<"destroy">>, xmlns = [<<"http://jabber.org/protocol/muc#user">>, <<"http://jabber.org/protocol/muc#owner">>], module = 'xep0045', result = {muc_destroy, '$xmlns', '$jid', '$reason', '$password'}, attrs = [#attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"xmlns">>}], refs = [#ref{name = muc_reason, min = 0, default = <<"">>, max = 1, label = '$reason'}, #ref{name = muc_password, min = 0, max = 1, label = '$password'}]}). -xml(muc_user_invite, #elem{name = <<"invite">>, xmlns = <<"http://jabber.org/protocol/muc#user">>, module = 'xep0045', result = {muc_invite, '$reason', '$from', '$to', '$continue'}, attrs = [#attr{name = <<"to">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"from">>, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = muc_reason, min = 0, default = <<"">>, max = 1, label = '$reason'}, #ref{name = muc_user_continue, min = 0, max = 1, label = '$continue'}]}). -xml(muc_user_actor, #elem{name = <<"actor">>, xmlns = <<"http://jabber.org/protocol/muc#user">>, module = 'xep0045', result = {muc_actor, '$jid', '$nick'}, attrs = [#attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"nick">>}]}). -xml(muc_user_continue, #elem{name = <<"continue">>, xmlns = <<"http://jabber.org/protocol/muc#user">>, module = 'xep0045', result = '$thread', attrs = [#attr{name = <<"thread">>}]}). -xml(muc_user_status, #elem{name = <<"status">>, xmlns = <<"http://jabber.org/protocol/muc#user">>, module = 'xep0045', result = '$code', attrs = [#attr{name = <<"code">>, dec = {dec_int, [100, 999]}, enc = {enc_int, []}}]}). -xml(muc_user_item, #elem{name = <<"item">>, xmlns = <<"http://jabber.org/protocol/muc#user">>, module = 'xep0045', result = {muc_item, '$actor', '$continue', '$reason', '$affiliation', '$role', '$jid', '$nick'}, refs = [#ref{name = muc_user_actor, min = 0, max = 1, label = '$actor'}, #ref{name = muc_user_continue, min = 0, max = 1, label = '$continue'}, #ref{name = muc_reason, default = <<"">>, min = 0, max = 1, label = '$reason'}], attrs = [#attr{name = <<"affiliation">>, dec = {dec_enum, [[admin, member, none, outcast, owner]]}, enc = {enc_enum, []}}, #attr{name = <<"role">>, dec = {dec_enum, [[moderator, none, participant, visitor]]}, enc = {enc_enum, []}}, #attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"nick">>}]}). -xml(muc_user, #elem{name = <<"x">>, xmlns = <<"http://jabber.org/protocol/muc#user">>, module = 'xep0045', result = {muc_user, '$decline', '$destroy', '$invites', '$items', '$status_codes', '$password'}, refs = [#ref{name = muc_user_decline, min = 0, max = 1, label = '$decline'}, #ref{name = muc_destroy, min = 0, max = 1, label = '$destroy'}, #ref{name = muc_password, min = 0, max = 1, label = '$password'}, #ref{name = muc_user_invite, label = '$invites'}, #ref{name = muc_user_item, label = '$items'}, #ref{name = muc_user_status, label = '$status_codes'}]}). -xml(muc_password, #elem{name = <<"password">>, xmlns = [<<"http://jabber.org/protocol/muc#owner">>, <<"http://jabber.org/protocol/muc#user">>, <<"http://jabber.org/protocol/muc">>], module = 'xep0045', result = '$cdata'}). -xml(muc_owner, #elem{name = <<"query">>, xmlns = <<"http://jabber.org/protocol/muc#owner">>, module = 'xep0045', result = {muc_owner, '$destroy', '$config', '$items'}, refs = [#ref{name = muc_destroy, min = 0, max = 1, label = '$destroy'}, #ref{name = xdata, min = 0, max = 1, label = '$config'}, #ref{name = muc_owner_item, label = '$items'}]}). -xml(muc_owner_item, #elem{name = <<"item">>, xmlns = <<"http://jabber.org/protocol/muc#owner">>, module = 'xep0045', result = {muc_item, '$actor', '$continue', '$reason', '$affiliation', '$role', '$jid', '$nick'}, refs = [#ref{name = muc_admin_actor, min = 0, max = 1, label = '$actor'}, #ref{name = muc_admin_continue, min = 0, max = 1, label = '$continue'}, #ref{name = muc_reason, default = <<"">>, min = 0, max = 1, label = '$reason'}], attrs = [#attr{name = <<"affiliation">>, dec = {dec_enum, [[admin, member, none, outcast, owner]]}, enc = {enc_enum, []}}, #attr{name = <<"role">>, dec = {dec_enum, [[moderator, none, participant, visitor]]}, enc = {enc_enum, []}}, #attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"nick">>}]}). -xml(muc_admin_item, #elem{name = <<"item">>, xmlns = <<"http://jabber.org/protocol/muc#admin">>, module = 'xep0045', result = {muc_item, '$actor', '$continue', '$reason', '$affiliation', '$role', '$jid', '$nick'}, refs = [#ref{name = muc_admin_actor, min = 0, max = 1, label = '$actor'}, #ref{name = muc_admin_continue, min = 0, max = 1, label = '$continue'}, #ref{name = muc_reason, default = <<"">>, min = 0, max = 1, label = '$reason'}], attrs = [#attr{name = <<"affiliation">>, dec = {dec_enum, [[admin, member, none, outcast, owner]]}, enc = {enc_enum, []}}, #attr{name = <<"role">>, dec = {dec_enum, [[moderator, none, participant, visitor]]}, enc = {enc_enum, []}}, #attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"nick">>}]}). -xml(muc_admin_actor, #elem{name = <<"actor">>, xmlns = <<"http://jabber.org/protocol/muc#admin">>, module = 'xep0045', result = {muc_actor, '$jid', '$nick'}, attrs = [#attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"nick">>}]}). -xml(muc_admin_continue, #elem{name = <<"continue">>, xmlns = <<"http://jabber.org/protocol/muc#admin">>, module = 'xep0045', result = '$thread', attrs = [#attr{name = <<"thread">>}]}). -xml(muc_admin, #elem{name = <<"query">>, xmlns = <<"http://jabber.org/protocol/muc#admin">>, module = 'xep0045', result = {muc_admin, '$items'}, refs = [#ref{name = muc_admin_item, label = '$items'}]}). -xml(muc, #elem{name = <<"x">>, xmlns = <<"http://jabber.org/protocol/muc">>, module = 'xep0045', result = {muc, '$history', '$password'}, refs = [#ref{name = muc_history, min = 0, max = 1, label = '$history'}, #ref{name = muc_password, min = 0, max = 1, label = '$password'}]}). -xml(muc_unique, #elem{name = <<"unique">>, xmlns = <<"http://jabber.org/protocol/muc#unique">>, module = 'xep0045', result = {muc_unique, '$name'}, cdata = #cdata{default = <<"">>, label = '$name'}}). -xml(x_conference, #elem{name = <<"x">>, xmlns = <<"jabber:x:conference">>, module = 'xep0249', result = {x_conference, '$jid', '$password', '$reason', '$continue', '$thread'}, attrs = [#attr{name = <<"jid">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"password">>, default = <<"">>}, #attr{name = <<"reason">>, default = <<"">>}, #attr{name = <<"thread">>, default = <<"">>}, #attr{name = <<"continue">>, dec = {dec_bool, []}, enc = {enc_bool, []}}]}). -xml(muc_subscription, #elem{name = <<"subscription">>, xmlns = <<"urn:xmpp:mucsub:0">>, module = p1_mucsub, result = {muc_subscription, '$jid', '$nick', '$events'}, attrs = [#attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"nick">>}], refs = [#ref{name = muc_subscribe_event, label = '$events'}]}). -xml(muc_subscriptions, #elem{name = <<"subscriptions">>, xmlns = <<"urn:xmpp:mucsub:0">>, module = p1_mucsub, result = {muc_subscriptions, '$list'}, refs = [#ref{name = muc_subscription, label = '$list'}]}). -xml(muc_subscribe_event, #elem{name = <<"event">>, xmlns = <<"urn:xmpp:mucsub:0">>, module = p1_mucsub, result = '$node', attrs = [#attr{name = <<"node">>, required = true}]}). -xml(muc_subscribe, #elem{name = <<"subscribe">>, xmlns = <<"urn:xmpp:mucsub:0">>, module = p1_mucsub, result = {muc_subscribe, '$nick', '$password', '$jid', '$events'}, attrs = [#attr{name = <<"nick">>, required = true}, #attr{name = <<"password">>}, #attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = muc_subscribe_event, label = '$events'}]}). -xml(muc_unsubscribe, #elem{name = <<"unsubscribe">>, xmlns = <<"urn:xmpp:mucsub:0">>, module = p1_mucsub, attrs = [#attr{name = <<"nick">>}, #attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}}], result = {muc_unsubscribe, '$nick', '$jid'}}). -xml(rsm_after, #elem{name = <<"after">>, xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', cdata = #cdata{required = true}, result = '$cdata'}). -xml(rsm_before, #elem{name = <<"before">>, xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', cdata = #cdata{default = <<"">>}, result = '$cdata'}). -xml(rsm_last, #elem{name = <<"last">>, xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', result = '$cdata'}). -xml(rsm_count, #elem{name = <<"count">>, result = '$cdata', xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', cdata = #cdata{dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}}). -xml(rsm_index, #elem{name = <<"index">>, result = '$cdata', xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', cdata = #cdata{dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}}). -xml(rsm_max, #elem{name = <<"max">>, result = '$cdata', xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', cdata = #cdata{dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}}). -xml(rsm_first, #elem{name = <<"first">>, xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', result = {rsm_first, '$index', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"index">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}]}). -xml(rsm_set, #elem{name = <<"set">>, xmlns = <<"http://jabber.org/protocol/rsm">>, module = 'xep0059', result = {rsm_set, '$after', '$before', '$count', '$first', '$index', '$last', '$max'}, refs = [#ref{name = rsm_after, label = '$after', min = 0, max = 1}, #ref{name = rsm_before, label = '$before', min = 0, max = 1}, #ref{name = rsm_count, label = '$count', min = 0, max = 1}, #ref{name = rsm_first, label = '$first', min = 0, max = 1}, #ref{name = rsm_index, label = '$index', min = 0, max = 1}, #ref{name = rsm_last, label = '$last', min = 0, max = 1}, #ref{name = rsm_max, label = '$max', min = 0, max = 1}]}). -xml(mam_start, #elem{name = <<"start">>, xmlns = <<"urn:xmpp:mam:tmp">>, module = 'xep0313', result = '$cdata', cdata = #cdata{required = true, dec = {dec_utc, []}, enc = {enc_utc, []}}}). -xml(mam_end, #elem{name = <<"end">>, xmlns = <<"urn:xmpp:mam:tmp">>, module = 'xep0313', result = '$cdata', cdata = #cdata{required = true, dec = {dec_utc, []}, enc = {enc_utc, []}}}). -xml(mam_with, #elem{name = <<"with">>, xmlns = <<"urn:xmpp:mam:tmp">>, module = 'xep0313', result = '$cdata', cdata = #cdata{required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}}). -xml(mam_withtext, #elem{name = <<"withtext">>, xmlns = <<"urn:xmpp:mam:tmp">>, module = 'xep0313', result = '$cdata', cdata = #cdata{required = true}}). -xml(mam_query, #elem{name = <<"query">>, xmlns = [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], module = 'xep0313', result = {mam_query, '$xmlns', '$id', '$start', '$end', '$with', '$withtext', '$rsm', '$xdata'}, attrs = [#attr{name = <<"queryid">>, label = '$id'}, #attr{name = <<"xmlns">>}], refs = [#ref{name = mam_start, min = 0, max = 1, label = '$start'}, #ref{name = mam_end, min = 0, max = 1, label = '$end'}, #ref{name = mam_with, min = 0, max = 1, label = '$with'}, #ref{name = mam_withtext, min = 0, max = 1, label = '$withtext'}, #ref{name = rsm_set, min = 0, max = 1, label = '$rsm'}, #ref{name = xdata, min = 0, max = 1, label = '$xdata'}]}). -xml(mam_archived, #elem{name = <<"archived">>, xmlns = <<"urn:xmpp:mam:tmp">>, module = 'xep0313', result = {mam_archived, '$by', '$id'}, attrs = [#attr{name = <<"id">>}, #attr{name = <<"by">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}]}). -xml(mam_result, #elem{name = <<"result">>, xmlns = [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], module = 'xep0313', result = {mam_result, '$xmlns', '$queryid', '$id', '$_els'}, attrs = [#attr{name = <<"queryid">>}, #attr{name = <<"xmlns">>}, #attr{name = <<"id">>}]}). -xml(mam_jid, #elem{name = <<"jid">>, xmlns = [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], module = 'xep0313', result = '$cdata', cdata = #cdata{required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}}). -xml(mam_never, #elem{name = <<"never">>, xmlns = [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], module = 'xep0313', result = '$jids', refs = [#ref{name = mam_jid, label = '$jids'}]}). -xml(mam_always, #elem{name = <<"always">>, xmlns = [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], module = 'xep0313', result = '$jids', refs = [#ref{name = mam_jid, label = '$jids'}]}). -xml(mam_prefs, #elem{name = <<"prefs">>, xmlns = [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], module = 'xep0313', result = {mam_prefs, '$xmlns', '$default', '$always', '$never'}, attrs = [#attr{name = <<"default">>, dec = {dec_enum, [[always, never, roster]]}, enc = {enc_enum, []}}, #attr{name = <<"xmlns">>}], refs = [#ref{name = mam_always, label = '$always', min = 0, max = 1}, #ref{name = mam_never, label = '$never', min = 0, max = 1}]}). -xml(mam_fin, #elem{name = <<"fin">>, xmlns = [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>], module = 'xep0313', result = {mam_fin, '$xmlns', '$id', '$rsm', '$stable', '$complete'}, attrs = [#attr{name = <<"queryid">>, label = '$id'}, #attr{name = <<"xmlns">>}, #attr{name = <<"stable">>, label = '$stable', dec = {dec_bool, []}, enc = {enc_bool, []}}, #attr{name = <<"complete">>, label = '$complete', dec = {dec_bool, []}, enc = {enc_bool, []}}], refs = [#ref{name = rsm_set, min = 0, max = 1, label = '$rsm'}]}). -xml(forwarded, #elem{name = <<"forwarded">>, xmlns = <<"urn:xmpp:forward:0">>, module = 'xep0297', ignore_els = true, result = {forwarded, '$delay', '$_els'}, refs = [#ref{name = delay, min = 0, max = 1, label = '$delay'}]}). -xml(carbons_disable, #elem{name = <<"disable">>, xmlns = <<"urn:xmpp:carbons:2">>, module = 'xep0280', result = {carbons_disable}}). -xml(carbons_enable, #elem{name = <<"enable">>, xmlns = <<"urn:xmpp:carbons:2">>, module = 'xep0280', result = {carbons_enable}}). -xml(carbons_private, #elem{name = <<"private">>, xmlns = <<"urn:xmpp:carbons:2">>, module = 'xep0280', result = {carbons_private}}). -xml(carbons_received, #elem{name = <<"received">>, xmlns = <<"urn:xmpp:carbons:2">>, module = 'xep0280', result = {carbons_received, '$forwarded'}, refs = [#ref{name = forwarded, min = 1, max = 1, label = '$forwarded'}]}). -xml(carbons_sent, #elem{name = <<"sent">>, xmlns = <<"urn:xmpp:carbons:2">>, module = 'xep0280', result = {carbons_sent, '$forwarded'}, refs = [#ref{name = forwarded, min = 1, max = 1, label = '$forwarded'}]}). -xml(feature_csi, #elem{name = <<"csi">>, xmlns = <<"urn:xmpp:csi:0">>, module = 'xep0352', result = {feature_csi}}). -record(csi, {type :: active | inactive}). -type csi() :: #csi{}. -xml(csi_active, #elem{name = <<"active">>, xmlns = <<"urn:xmpp:csi:0">>, module = 'xep0352', result = {csi, active}}). -xml(csi_inactive, #elem{name = <<"inactive">>, xmlns = <<"urn:xmpp:csi:0">>, module = 'xep0352', result = {csi, inactive}}). -xml(feature_sm, #elem{name = <<"sm">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {feature_sm, '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}]}). -xml(sm_enable, #elem{name = <<"enable">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {sm_enable, '$max', '$resume', '$xmlns'}, attrs = [#attr{name = <<"max">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"xmlns">>}, #attr{name = <<"resume">>, default = false, dec = {dec_bool, []}, enc = {enc_bool, []}}]}). -xml(sm_enabled, #elem{name = <<"enabled">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {sm_enabled, '$id', '$location', '$max', '$resume', '$xmlns'}, attrs = [#attr{name = <<"id">>}, #attr{name = <<"location">>}, #attr{name = <<"xmlns">>}, #attr{name = <<"max">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"resume">>, default = false, dec = {dec_bool, []}, enc = {enc_bool, []}}]}). -xml(sm_resume, #elem{name = <<"resume">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {sm_resume, '$h', '$previd', '$xmlns'}, attrs = [#attr{name = <<"h">>, required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"xmlns">>}, #attr{name = <<"previd">>, required = true}]}). -xml(sm_resumed, #elem{name = <<"resumed">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {sm_resumed, '$h', '$previd', '$xmlns'}, attrs = [#attr{name = <<"h">>, required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"xmlns">>}, #attr{name = <<"previd">>, required = true}]}). -xml(sm_r, #elem{name = <<"r">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {sm_r, '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}]}). -xml(sm_a, #elem{name = <<"a">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {sm_a, '$h', '$xmlns'}, attrs = [#attr{name = <<"h">>, required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"xmlns">>}]}). -xml(sm_failed, #elem{name = <<"failed">>, xmlns = [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], module = 'xep0198', result = {sm_failed, '$reason', '$text', '$h', '$xmlns'}, attrs = [#attr{name = <<"h">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"xmlns">>}], refs = [#ref{name = error_text, label = '$text'}, #ref{name = error_bad_request, min = 0, max = 1, label = '$reason'}, #ref{name = error_conflict, min = 0, max = 1, label = '$reason'}, #ref{name = error_feature_not_implemented, min = 0, max = 1, label = '$reason'}, #ref{name = error_forbidden, min = 0, max = 1, label = '$reason'}, #ref{name = error_gone, min = 0, max = 1, label = '$reason'}, #ref{name = error_internal_server_error, min = 0, max = 1, label = '$reason'}, #ref{name = error_item_not_found, min = 0, max = 1, label = '$reason'}, #ref{name = error_jid_malformed, min = 0, max = 1, label = '$reason'}, #ref{name = error_not_acceptable, min = 0, max = 1, label = '$reason'}, #ref{name = error_not_allowed, min = 0, max = 1, label = '$reason'}, #ref{name = error_not_authorized, min = 0, max = 1, label = '$reason'}, #ref{name = error_policy_violation, min = 0, max = 1, label = '$reason'}, #ref{name = error_recipient_unavailable, min = 0, max = 1, label = '$reason'}, #ref{name = error_redirect, min = 0, max = 1, label = '$reason'}, #ref{name = error_registration_required, min = 0, max = 1, label = '$reason'}, #ref{name = error_remote_server_not_found, min = 0, max = 1, label = '$reason'}, #ref{name = error_remote_server_timeout, min = 0, max = 1, label = '$reason'}, #ref{name = error_resource_constraint, min = 0, max = 1, label = '$reason'}, #ref{name = error_service_unavailable, min = 0, max = 1, label = '$reason'}, #ref{name = error_subscription_required, min = 0, max = 1, label = '$reason'}, #ref{name = error_undefined_condition, min = 0, max = 1, label = '$reason'}, #ref{name = error_unexpected_request, min = 0, max = 1, label = '$reason'}]}). -xml(offline_purge, #elem{name = <<"purge">>, xmlns = <<"http://jabber.org/protocol/offline">>, module = 'xep0013', result = true}). -xml(offline_fetch, #elem{name = <<"fetch">>, xmlns = <<"http://jabber.org/protocol/offline">>, module = 'xep0013', result = true}). -xml(offline_item, #elem{name = <<"item">>, xmlns = <<"http://jabber.org/protocol/offline">>, module = 'xep0013', result = {offline_item, '$node', '$action'}, attrs = [#attr{name = <<"node">>}, #attr{name = <<"action">>, dec = {dec_enum, [[view, remove]]}, enc = {enc_enum, []}}]}). -xml(offline, #elem{name = <<"offline">>, xmlns = <<"http://jabber.org/protocol/offline">>, module = 'xep0013', result = {offline, '$items', '$purge', '$fetch'}, refs = [#ref{name = offline_purge, min = 0, max = 1, label = '$purge', default = false}, #ref{name = offline_fetch, min = 0, max = 1, label = '$fetch', default = false}, #ref{name = offline_item, min = 0, label = '$items'}]}). -xml(mix_subscribe, #elem{name = <<"subscribe">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = '$node', attrs = [#attr{name = <<"node">>, required = true, label = '$node'}]}). -xml(mix_nick, #elem{name = <<"nick">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = '$cdata', cdata = #cdata{required = true}}). -xml(mix_jid, #elem{name = <<"jid">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = '$cdata', cdata = #cdata{required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}}). -xml(mix_submission_id, #elem{name = <<"submission-id">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = '$cdata', cdata = #cdata{required = true}}). -xml(mix_setnick, #elem{name = <<"setnick">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = {mix_setnick, '$nick'}, refs = [#ref{name = mix_nick, min = 1, max = 1, label = '$nick'}]}). -xml(mix_join, #elem{name = <<"join">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = {mix_join, '$id', '$jid', '$nick', '$subscribe'}, attrs = [#attr{name = <<"id">>}, #attr{name = <<"jid">>, label = '$jid', dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = mix_subscribe, min = 0, label = '$subscribe'}, #ref{name = mix_nick, default = <<"">>, min = 0, max = 1, label = '$nick'}]}). -xml(mix_client_join, #elem{name = <<"client-join">>, xmlns = <<"urn:xmpp:mix:pam:0">>, module = 'xep0405', result = {mix_client_join, '$channel', '$join'}, attrs = [#attr{name = <<"channel">>, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = mix_join, min = 1, max = 1, label = '$join'}]}). -xml(mix_leave, #elem{name = <<"leave">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = {mix_leave}}). -xml(mix_client_leave, #elem{name = <<"client-leave">>, xmlns = <<"urn:xmpp:mix:pam:0">>, module = 'xep0405', result = {mix_client_leave, '$channel', '$leave'}, attrs = [#attr{name = <<"channel">>, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = mix_leave, min = 1, max = 1, label = '$leave'}]}). -xml(mix_participant, #elem{name = <<"participant">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = {mix_participant, '$jid', '$nick'}, attrs = [#attr{name = <<"jid">>, required = true, label = '$jid', dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"nick">>, label = '$nick'}]}). -xml(mix_create, #elem{name = <<"create">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = {mix_create, '$channel'}, attrs = [#attr{name = <<"channel">>, default = <<"">>, dec = {nodeprep, []}}]}). -xml(mix_destroy, #elem{name = <<"destroy">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = {mix_destroy, '$channel'}, attrs = [#attr{name = <<"channel">>, dec = {jid, nodeprep, []}, required = true}]}). -xml(mix, #elem{name = <<"mix">>, xmlns = <<"urn:xmpp:mix:core:0">>, module = 'xep0369', result = {mix, '$submission_id', '$jid', '$nick'}, refs = [#ref{name = mix_submission_id, default = <<"">>, min = 0, max = 1, label = '$submission_id'}, #ref{name = mix_jid, min = 0, max = 1, label = '$jid'}, #ref{name = mix_nick, min = 0, max = 1, label = '$nick', default = <<"">>}]}). -record(hint, {type :: 'no-copy' | 'no-store' | 'no-storage' | 'store' | 'no-permanent-store' | 'no-permanent-storage'}). -type hint() :: #hint{}. -xml(hint_no_copy, #elem{name = <<"no-copy">>, xmlns = <<"urn:xmpp:hints">>, module = 'xep0334', result = {hint, 'no-copy'}}). -xml(hint_no_store, #elem{name = <<"no-store">>, xmlns = <<"urn:xmpp:hints">>, module = 'xep0334', result = {hint, 'no-store'}}). -xml(hint_no_storage, #elem{name = <<"no-storage">>, xmlns = <<"urn:xmpp:hints">>, module = 'xep0334', result = {hint, 'no-storage'}}). -xml(hint_store, #elem{name = <<"store">>, xmlns = <<"urn:xmpp:hints">>, module = 'xep0334', result = {hint, 'store'}}). -xml(hint_no_permanent_store, #elem{name = <<"no-permanent-store">>, xmlns = <<"urn:xmpp:hints">>, module = 'xep0334', result = {hint, 'no-permanent-store'}}). -xml(hint_no_permanent_storage, #elem{name = <<"no-permanent-storage">>, xmlns = <<"urn:xmpp:hints">>, module = 'xep0334', result = {hint, 'no-permanent-storage'}}). -xml(search_instructions, #elem{name = <<"instructions">>, xmlns = <<"jabber:iq:search">>, module = 'xep0055', result = '$cdata'}). -xml(search_first, #elem{name = <<"first">>, xmlns = <<"jabber:iq:search">>, module = 'xep0055', cdata = #cdata{default = <<"">>}, result = '$cdata'}). -xml(search_last, #elem{name = <<"last">>, xmlns = <<"jabber:iq:search">>, module = 'xep0055', cdata = #cdata{default = <<"">>}, result = '$cdata'}). -xml(search_nick, #elem{name = <<"nick">>, xmlns = <<"jabber:iq:search">>, module = 'xep0055', cdata = #cdata{default = <<"">>}, result = '$cdata'}). -xml(search_email, #elem{name = <<"email">>, xmlns = <<"jabber:iq:search">>, module = 'xep0055', cdata = #cdata{default = <<"">>}, result = '$cdata'}). -xml(search_item, #elem{name = <<"item">>, xmlns = <<"jabber:iq:search">>, module = 'xep0055', result = {search_item, '$jid', '$first', '$last', '$nick', '$email'}, attrs = [#attr{name = <<"jid">>, required = true, enc = {jid, encode, []}, dec = {jid, decode, []}}], refs = [#ref{name = search_first, min = 0, max = 1, label = '$first'}, #ref{name = search_last, min = 0, max = 1, label = '$last'}, #ref{name = search_nick, min = 0, max = 1, label = '$nick'}, #ref{name = search_email, min = 0, max = 1, label = '$email'}]}). -xml(search, #elem{name = <<"query">>, xmlns = <<"jabber:iq:search">>, module = 'xep0055', result = {search, '$instructions', '$first', '$last', '$nick', '$email', '$items', '$xdata'}, refs = [#ref{name = search_instructions, min = 0, max = 1, label = '$instructions'}, #ref{name = search_first, min = 0, max = 1, label = '$first'}, #ref{name = search_last, min = 0, max = 1, label = '$last'}, #ref{name = search_nick, min = 0, max = 1, label = '$nick'}, #ref{name = search_email, min = 0, max = 1, label = '$email'}, #ref{name = search_item, label = '$items'}, #ref{name = xdata, min = 0, max = 1, label = '$xdata'}]}). -xml(xevent_offline, #elem{name = <<"offline">>, xmlns = <<"jabber:x:event">>, module = 'xep0022', result = true}). -xml(xevent_delivered, #elem{name = <<"delivered">>, xmlns = <<"jabber:x:event">>, module = 'xep0022', result = true}). -xml(xevent_displayed, #elem{name = <<"displayed">>, xmlns = <<"jabber:x:event">>, module = 'xep0022', result = true}). -xml(xevent_composing, #elem{name = <<"composing">>, xmlns = <<"jabber:x:event">>, module = 'xep0022', result = true}). -xml(xevent_id, #elem{name = <<"id">>, xmlns = <<"jabber:x:event">>, module = 'xep0022', cdata = #cdata{}, result = '$cdata'}). -xml(xevent, #elem{name = <<"x">>, xmlns = <<"jabber:x:event">>, module = 'xep0022', result = {xevent, '$offline', '$delivered', '$displayed', '$composing', '$id'}, refs = [#ref{name = xevent_offline, min = 0, max = 1, label = '$offline', default = false}, #ref{name = xevent_delivered, min = 0, max = 1, label = '$delivered', default = false}, #ref{name = xevent_displayed, min = 0, max = 1, label = '$displayed', default = false}, #ref{name = xevent_composing, min = 0, max = 1, label = '$composing', default = false}, #ref{name = xevent_id, min = 0, max = 1, label = '$id'}]}). -xml(expire, #elem{name = <<"x">>, xmlns = <<"jabber:x:expire">>, module = 'xep0023', result = {expire, '$seconds', '$stored'}, attrs = [#attr{name = <<"seconds">>, required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"stored">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}]}). -xml(nick, #elem{name = <<"nick">>, xmlns = <<"http://jabber.org/protocol/nick">>, module = 'xep0172', result = {nick, '$name'}, cdata = #cdata{label = '$name', required = true}}). -xml(address, #elem{name = <<"address">>, xmlns = <<"http://jabber.org/protocol/address">>, module = 'xep0033', result = {address, '$type', '$jid', '$desc', '$node', '$delivered'}, attrs = [#attr{name = <<"type">>, required = true, dec = {dec_enum, [[bcc, cc, noreply, ofrom, replyroom, replyto, to]]}, enc = {enc_enum, []}}, #attr{name = <<"jid">>, enc = {jid, encode, []}, dec = {jid, decode, []}}, #attr{name = <<"desc">>}, #attr{name = <<"node">>}, #attr{name = <<"delivered">>, enc = {enc_bool, []}, dec = {dec_bool, []}}]}). -xml(addresses, #elem{name = <<"addresses">>, xmlns = <<"http://jabber.org/protocol/address">>, module = 'xep0033', result = {addresses, '$list'}, %% TODO: 'min' should be '1', but this is not implemented refs = [#ref{name = address, label = '$list'}]}). -xml(stanza_id, #elem{name = <<"stanza-id">>, xmlns = <<"urn:xmpp:sid:0">>, module = 'xep0359', result = {stanza_id, '$by', '$id'}, attrs = [#attr{name = <<"id">>, required = true}, #attr{name = <<"by">>, required = true, enc = {jid, encode, []}, dec = {jid, decode, []}}]}). -xml(origin_id, #elem{name = <<"origin-id">>, xmlns = <<"urn:xmpp:sid:0">>, module = 'xep0359', result = {origin_id, '$id'}, attrs = [#attr{name = <<"id">>, required = true}]}). -xml(adhoc_command_prev, #elem{name = <<"prev">>, xmlns = <<"http://jabber.org/protocol/commands">>, module = 'xep0050', result = true}). -xml(adhoc_command_next, #elem{name = <<"next">>, xmlns = <<"http://jabber.org/protocol/commands">>, module = 'xep0050', result = true}). -xml(adhoc_command_complete, #elem{name = <<"complete">>, xmlns = <<"http://jabber.org/protocol/commands">>, module = 'xep0050', result = true}). -xml(adhoc_command_actions, #elem{name = <<"actions">>, xmlns = <<"http://jabber.org/protocol/commands">>, module = 'xep0050', result = {adhoc_actions, '$execute', '$prev', '$next', '$complete'}, attrs = [#attr{name = <<"execute">>, dec = {dec_enum, [[complete, next, prev]]}, enc = {enc_enum, []}}], refs = [#ref{name = adhoc_command_prev, min = 0, max = 1, default = false, label = '$prev'}, #ref{name = adhoc_command_next, min = 0, max = 1, default = false, label = '$next'}, #ref{name = adhoc_command_complete, min = 0, max = 1, default = false, label = '$complete'}]}). -xml(adhoc_command_notes, #elem{name = <<"note">>, xmlns = <<"http://jabber.org/protocol/commands">>, module = 'xep0050', result = {adhoc_note, '$type', '$data'}, attrs = [#attr{name = <<"type">>, default = info, dec = {dec_enum, [[info, warn, error]]}, enc = {enc_enum, []}}], cdata = #cdata{default = <<"">>, label = '$data'}}). -xml(adhoc_command, #elem{name = <<"command">>, xmlns = <<"http://jabber.org/protocol/commands">>, module = 'xep0050', result = {adhoc_command, '$node', '$action', '$sid', '$status', '$lang', '$actions', '$notes', '$xdata'}, attrs = [#attr{name = <<"node">>, required = true}, #attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}, #attr{name = <<"sessionid">>, label = '$sid'}, #attr{name = <<"status">>, dec = {dec_enum, [[canceled, completed, executing]]}, enc = {enc_enum, []}}, #attr{name = <<"action">>, default = execute, dec = {dec_enum, [[cancel, complete, execute, next, prev]]}, enc = {enc_enum, []}}], refs = [#ref{name = adhoc_command_actions, min = 0, max = 1, label = '$actions'}, #ref{name = xdata, min = 0, max = 1}, #ref{name = adhoc_command_notes, label = '$notes'}]}). -xml(db_result, #elem{name = <<"db:result">>, xmlns = <<"jabber:server">>, module = 'xep0220', result = {db_result, '$from', '$to', '$type', '$key', '$_els'}, cdata = #cdata{default = <<"">>, label = '$key'}, attrs = [#attr{name = <<"from">>, required = true, dec = {nameprep, []}, enc = {nameprep, []}}, #attr{name = <<"to">>, required = true, dec = {nameprep, []}, enc = {nameprep, []}}, #attr{name = <<"type">>, dec = {dec_enum, [[valid, invalid, error]]}, enc = {enc_enum, []}}]}). -xml(db_verify, #elem{name = <<"db:verify">>, xmlns = <<"jabber:server">>, module = 'xep0220', result = {db_verify, '$from', '$to', '$id', '$type', '$key', '$_els'}, cdata = #cdata{default = <<"">>, label = '$key'}, attrs = [#attr{name = <<"from">>, required = true, dec = {nameprep, []}, enc = {nameprep, []}}, #attr{name = <<"to">>, required = true, dec = {nameprep, []}, enc = {nameprep, []}}, #attr{name = <<"id">>, required = true}, #attr{name = <<"type">>, dec = {dec_enum, [[valid, invalid, error]]}, enc = {enc_enum, []}}]}). -xml(db_errors, #elem{name = <<"errors">>, xmlns = <<"urn:xmpp:features:dialback">>, module = 'xep0220', result = true}). -xml(db_feature, #elem{name = <<"dialback">>, xmlns = <<"urn:xmpp:features:dialback">>, module = 'xep0220', result = {db_feature, '$errors'}, refs = [#ref{name = db_errors, min = 0, max = 1, default = false, label = '$errors'}]}). -xml(handshake, #elem{name = <<"handshake">>, xmlns = <<"jabber:component:accept">>, module = 'xep0114', result = {handshake, '$data'}, cdata = #cdata{default = <<"">>, label = '$data'}}). -xml(stream_start, #elem{name = <<"stream:stream">>, xmlns = [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], module = rfc6120, result = {stream_start, '$from', '$to', '$id', '$version', '$xmlns', '$stream_xmlns', '$db_xmlns', '$lang'}, attrs = [#attr{name = <<"from">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"to">>, dec = {jid, decode, []}, enc = {jid, encode, []}}, #attr{name = <<"xmlns">>}, #attr{name = <<"xmlns:stream">>, label = '$stream_xmlns', default = <<"">>}, #attr{name = <<"xmlns:db">>, label = '$db_xmlns', default = <<"">>}, #attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang', default = <<"">>}, #attr{name = <<"version">>, dec = {dec_version, []}, enc = {enc_version, []}}, #attr{name = <<"id">>, default = <<"">>}]}). -xml(bob_data, #elem{name = <<"data">>, xmlns = <<"urn:xmpp:bob">>, module = 'xep0231', result = {bob_data, '$cid', '$max-age', '$type', '$data'}, attrs = [#attr{name = <<"cid">>, required = true}, #attr{name = <<"max-age">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"type">>}], cdata = #cdata{label = '$data', default = <<"">>, dec = {base64, decode, []}, enc = {base64, encode, []}}}). -xml(captcha, #elem{name = <<"captcha">>, xmlns = <<"urn:xmpp:captcha">>, module = 'xep0158', result = {xcaptcha, '$xdata'}, refs = [#ref{name = xdata, min = 1, max = 1}]}). -xml(media_uri, #elem{name = <<"uri">>, xmlns = <<"urn:xmpp:media-element">>, module = 'xep0221', result = {media_uri, '$type', '$uri'}, attrs = [#attr{name = <<"type">>, required = true}], cdata = #cdata{label = '$uri', default = <<"">>}}). -xml(media, #elem{name = <<"media">>, xmlns = <<"urn:xmpp:media-element">>, module = 'xep0221', result = {media, '$height', '$width', '$uri'}, attrs = [#attr{name = <<"height">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"width">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}], refs = [#ref{name = media_uri, label = '$uri'}]}). -xml(oob_url, #elem{name = <<"url">>, xmlns = <<"jabber:x:oob">>, module = 'xep0066', result = '$cdata', cdata = #cdata{required = true}}). -xml(oob_desc, #elem{name = <<"desc">>, xmlns = <<"jabber:x:oob">>, module = 'xep0066', result = '$cdata', cdata = #cdata{default = <<"">>}}). -xml(oob_x, #elem{name = <<"x">>, xmlns = <<"jabber:x:oob">>, module = 'xep0066', result = {oob_x, '$url', '$desc', '$sid'}, attrs = [#attr{name = <<"sid">>, default = <<"">>}], refs = [#ref{name = oob_url, min = 1, max = 1, label = '$url'}, #ref{name = oob_desc, default = <<"">>, min = 0, max = 1, label = '$desc'}]}). -xml(receipt_request, #elem{name = <<"request">>, xmlns = <<"urn:xmpp:receipts">>, module = 'xep0184', result = {receipt_request}}). -xml(receipt_response, #elem{name = <<"received">>, xmlns = <<"urn:xmpp:receipts">>, module = 'xep0184', result = {receipt_response, '$id'}, attrs = [#attr{name = <<"id">>}]}). -xml(sic_ip, #elem{name = <<"ip">>, xmlns = [<<"urn:xmpp:sic:0">>, <<"urn:xmpp:sic:1">>], module = 'xep0279', result = '$cdata', cdata = #cdata{required = true, dec = {dec_ip, []}, enc = {enc_ip, []}}}). -xml(sic_port, #elem{name = <<"port">>, xmlns = <<"urn:xmpp:sic:1">>, module = 'xep0279', result = '$cdata', cdata = #cdata{required = true, dec = {dec_int, [0, 65535]}, enc = {enc_int, []}}}). -xml(sic, #elem{name = <<"address">>, xmlns = [<<"urn:xmpp:sic:0">>, <<"urn:xmpp:sic:1">>], module = 'xep0279', result = {sic, '$ip', '$port', '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}], refs = [#ref{name = sic_ip, min = 0, max = 1, label = '$ip'}, #ref{name = sic_port, min = 0, max = 1, label = '$port'}]}). -xml(upload_filename, #elem{name = <<"filename">>, xmlns = [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = '$cdata', cdata = #cdata{required = true}}). -xml(upload_size, #elem{name = <<"size">>, xmlns = [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = '$cdata', cdata = #cdata{required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}}). -xml(upload_content_type, #elem{name = <<"content-type">>, xmlns = [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = '$cdata', cdata = #cdata{default = <<"">>}}). -xml(upload_request, #elem{name = <<"request">>, xmlns = [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = {upload_request, '$filename', '$size', '$content-type', '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}], refs = [#ref{name = upload_filename, label = '$filename', min = 1, max = 1}, #ref{name = upload_size, label = '$size', min = 1, max = 1}, #ref{name = upload_content_type, label = '$content-type', min = 0, max = 1, default = <<"">>}]}). -xml(upload_get, #elem{name = <<"get">>, xmlns = [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = '$cdata', cdata = #cdata{required = true}}). -xml(upload_put, #elem{name = <<"put">>, xmlns = [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = '$cdata', cdata = #cdata{required = true}}). -xml(upload_slot, #elem{name = <<"slot">>, xmlns = [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = {upload_slot, '$get', '$put', '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}], refs = [#ref{name = upload_get, min = 0, max = 1, label = '$get'}, #ref{name = upload_put, min = 0, max = 1, label = '$put'}]}). -xml(upload_request_0, #elem{name = <<"request">>, xmlns = <<"urn:xmpp:http:upload:0">>, module = 'xep0363', result = {upload_request_0, '$filename', '$size', '$content-type', '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}, #attr{name = <<"filename">>, required = true}, #attr{name = <<"size">>, dec = {dec_int, [1, infinity]}, enc = {enc_int, []}, required = true}, #attr{name = <<"content-type">>}]}). -xml(upload_get_0, #elem{name = <<"get">>, xmlns = <<"urn:xmpp:http:upload:0">>, module = 'xep0363', result = '$url', attrs = [#attr{name = <<"url">>, required = true}]}). -xml(upload_put_0, #elem{name = <<"put">>, xmlns = <<"urn:xmpp:http:upload:0">>, module = 'xep0363', result = '$url', attrs = [#attr{name = <<"url">>, required = true}]}). -xml(upload_slot_0, #elem{name = <<"slot">>, xmlns = <<"urn:xmpp:http:upload:0">>, module = 'xep0363', result = {upload_slot_0, '$get', '$put', '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}], refs = [#ref{name = upload_get_0, label = '$get', min = 1, max = 1}, #ref{name = upload_put_0, label = '$put', min = 1, max = 1}]}). -xml(upload_max_file_size, #elem{name = <<"max-file-size">>, xmlns = [<<"urn:xmpp:http:upload:0">>, <<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = '$cdata', cdata = #cdata{required = true, enc = {enc_int, []}, dec = {dec_int, []}}}). -xml(upload_file_too_large, #elem{name = <<"file-too-large">>, xmlns = [<<"urn:xmpp:http:upload:0">>, <<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], module = 'xep0363', result = {upload_file_too_large, '$max-file-size', '$xmlns'}, attrs = [#attr{name = <<"xmlns">>}], refs = [#ref{name = upload_max_file_size, label = '$max-file-size', min = 0, max = 1}]}). -xml(upload_retry, #elem{name = <<"retry">>, xmlns = <<"urn:xmpp:http:upload:0">>, module = 'xep0363', result = {upload_retry, '$stamp'}, attrs = [#attr{name = <<"stamp">>, dec = {dec_utc, []}, enc = {enc_utc, []}}]}). -xml(push_enable, #elem{name = <<"enable">>, xmlns = <<"urn:xmpp:push:0">>, module = 'xep0357', result = {push_enable, '$jid', '$node', '$xdata'}, attrs = [#attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}, required = true}, #attr{name = <<"node">>}], refs = [#ref{name = xdata, min = 0, max = 1}]}). -xml(push_disable, #elem{name = <<"disable">>, xmlns = <<"urn:xmpp:push:0">>, module = 'xep0357', result = {push_disable, '$jid', '$node'}, attrs = [#attr{name = <<"jid">>, dec = {jid, decode, []}, enc = {jid, encode, []}, required = true}, #attr{name = <<"node">>}]}). -xml(push_notification, #elem{name = <<"notification">>, xmlns = <<"urn:xmpp:push:0">>, module = 'xep0357', result = {push_notification, '$xdata'}, refs = [#ref{name = xdata, min = 0, max = 1}]}). -xml(thumbnail, #elem{name = <<"thumbnail">>, xmlns = <<"urn:xmpp:thumbs:1">>, module = 'xep0264', result = {thumbnail, '$uri', '$media-type', '$width', '$height'}, attrs = [#attr{name = <<"uri">>, required = true}, #attr{name = <<"media-type">>, default = <<"">>}, #attr{name = <<"width">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"height">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}]}). -xml(privilege_perm, #elem{name = <<"perm">>, xmlns = <<"urn:xmpp:privilege:1">>, module = 'xep0356', result = {privilege_perm, '$access', '$type'}, attrs = [#attr{name = <<"access">>, required = true, dec = {dec_enum, [[roster, message, presence]]}, enc = {enc_enum, []}}, #attr{name = <<"type">>, required = true, dec = {dec_enum, [[none, get, set, both, outgoing, roster, managed_entity]]}, enc = {enc_enum, []}}]}). -xml(privilege, #elem{name = <<"privilege">>, xmlns = <<"urn:xmpp:privilege:1">>, module = 'xep0356', result = {privilege, '$perms', '$forwarded'}, refs = [#ref{name = privilege_perm, label = '$perms'}, #ref{name = forwarded, min = 0, max = 1, label = '$forwarded'}]}). -xml(delegated_attribute, #elem{name = <<"attribute">>, xmlns = <<"urn:xmpp:delegation:1">>, module = 'xep0355', result = '$name', attrs = [#attr{name = <<"name">>, required = true}]}). -xml(delegated, #elem{name = <<"delegated">>, xmlns = <<"urn:xmpp:delegation:1">>, module = 'xep0355', result = {delegated, '$ns', '$attrs'}, attrs = [#attr{name = <<"namespace">>, label = '$ns', required = true}], refs = [#ref{name = delegated_attribute, label = '$attrs'}]}). -xml(delegation, #elem{name = <<"delegation">>, xmlns = <<"urn:xmpp:delegation:1">>, module = 'xep0355', result = {delegation, '$delegated', '$forwarded'}, refs = [#ref{name = delegated, label = '$delegated'}, #ref{name = forwarded, min = 0, max = 1, label = '$forwarded'}]}). -xml(delegate, #elem{name = <<"delegate">>, xmlns = <<"urn:xmpp:delegation:1">>, module = 'xep0355', result = '$namespace', attrs = [#attr{name = <<"namespace">>, required = true}]}). -xml(delegation_query, #elem{name = <<"query">>, xmlns = <<"urn:xmpp:delegation:1">>, module = 'xep0355', result = {delegation_query, '$to', '$delegate'}, attrs = [#attr{name = <<"to">>, required = true, dec = {jid, decode, []}, enc = {jid, encode, []}}], refs = [#ref{name = delegate, label = '$delegate'}]}). -xml(avatar_data, #elem{name = <<"data">>, xmlns = <<"urn:xmpp:avatar:data">>, module = 'xep0084', result = {avatar_data, '$data'}, cdata = #cdata{label = '$data', required = true, dec = {base64, decode, []}, enc = {base64, encode, []}}}). -xml(avatar_info, #elem{name = <<"info">>, xmlns = <<"urn:xmpp:avatar:metadata">>, module = 'xep0084', result = {avatar_info, '$bytes', '$id', '$type', '$height', '$width', '$url'}, attrs = [#attr{name = <<"bytes">>, required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"id">>, required = true}, #attr{name = <<"type">>, required = true}, #attr{name = <<"url">>}, #attr{name = <<"height">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"width">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}]}). -xml(avatar_pointer, #elem{name = <<"pointer">>, xmlns = <<"urn:xmpp:avatar:metadata">>, module = 'xep0084', ignore_els = true, result = {avatar_pointer, '$bytes', '$id', '$type', '$height', '$width', '$_els'}, attrs = [#attr{name = <<"bytes">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"id">>}, #attr{name = <<"type">>}, #attr{name = <<"height">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"width">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}]}). -xml(avatar_meta, #elem{name = <<"metadata">>, xmlns = <<"urn:xmpp:avatar:metadata">>, module = 'xep0084', result = {avatar_meta, '$info', '$pointer'}, refs = [#ref{name = avatar_info, label = '$info'}, #ref{name = avatar_pointer, label = '$pointer', min = 0, max = 1}]}). -xml(hash, #elem{name = <<"hash">>, xmlns = <<"urn:xmpp:hashes:2">>, module = 'xep0300', result = {hash, '$algo', '$data'}, attrs = [#attr{name = <<"algo">>, required = true}], cdata = #cdata{label = '$data', enc = {base64, encode, []}, dec = {base64, decode, []}}}). -xml(hash_used, #elem{name = <<"hash-used">>, xmlns = <<"urn:xmpp:hashes:2">>, module = 'xep0300', result = {hash_used, '$algo'}, attrs = [#attr{name = <<"algo">>, required = true}]}). -xml(ibb_open, #elem{name = <<"open">>, xmlns = <<"http://jabber.org/protocol/ibb">>, module = 'xep0047', result = {ibb_open, '$sid', '$block-size', '$stanza'}, attrs = [#attr{name = <<"sid">>, required = true}, #attr{name = <<"block-size">>, required = true, enc = {enc_int, []}, dec = {dec_int, [0, infinity]}}, #attr{name = <<"stanza">>, default = iq, enc = {enc_enum, []}, dec = {dec_enum, [[iq, message]]}}]}). -xml(ibb_data, #elem{name = <<"data">>, xmlns = <<"http://jabber.org/protocol/ibb">>, module = 'xep0047', result = {ibb_data, '$sid', '$seq', '$data'}, attrs = [#attr{name = <<"sid">>, required = true}, #attr{name = <<"seq">>, required = true, enc = {enc_int, []}, dec = {dec_int, [0, infinity]}}], cdata = #cdata{label = '$data', enc = {base64, encode, []}, dec = {base64, decode, []}}}). -xml(ibb_close, #elem{name = <<"close">>, xmlns = <<"http://jabber.org/protocol/ibb">>, module = 'xep0047', result = {ibb_close, '$sid'}, attrs = [#attr{name = <<"sid">>, required = true}]}). -xml(idle, #elem{name = <<"idle">>, xmlns = <<"urn:xmpp:idle:1">>, module = 'xep0319', result = {idle, '$since'}, attrs = [#attr{name = <<"since">>, required = true, enc = {enc_utc, []}, dec = {dec_utc, []}}]}). -record(jingle_error, {reason :: 'out-of-order' | 'tie-break' | 'unknown-session' | 'unsupported-info' | 'security-required'}). -type jingle_error() :: #jingle_error{}. -xml(jingle_error_out_of_order, #elem{name = <<"out-of-order">>, xmlns = <<"urn:xmpp:jingle:errors:1">>, module = 'xep0166', result = {jingle_error, 'out-of-order'}}). -xml(jingle_error_tie_break, #elem{name = <<"tie-break">>, xmlns = <<"urn:xmpp:jingle:errors:1">>, module = 'xep0166', result = {jingle_error, 'tie-break'}}). -xml(jingle_error_unknown_session, #elem{name = <<"unknown-session">>, xmlns = <<"urn:xmpp:jingle:errors:1">>, module = 'xep0166', result = {jingle_error, 'unknown-session'}}). -xml(jingle_error_unsupported_info, #elem{name = <<"unsupported-info">>, xmlns = <<"urn:xmpp:jingle:errors:1">>, module = 'xep0166', result = {jingle_error, 'unsupported-info'}}). -xml(jingle_error_security_required, #elem{name = <<"security-required">>, xmlns = <<"urn:xmpp:jingle:errors:1">>, module = 'xep0166', result = {jingle_error, 'security-required'}}). -xml(jingle_reason_alternative_session, #elem{name = <<"alternative-session">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'alternative-session'}). -xml(jingle_reason_busy, #elem{name = <<"busy">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'busy'}). -xml(jingle_reason_cancel, #elem{name = <<"cancel">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'cancel'}). -xml(jingle_reason_connectivity_error, #elem{name = <<"connectivity-error">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'connectivity-error'}). -xml(jingle_reason_decline, #elem{name = <<"decline">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'decline'}). -xml(jingle_reason_expired, #elem{name = <<"expired">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'expired'}). -xml(jingle_reason_failed_application, #elem{name = <<"failed-application">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'failed-application'}). -xml(jingle_reason_failed_transport, #elem{name = <<"failed-transport">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'failed-transport'}). -xml(jingle_reason_general_error, #elem{name = <<"general-error">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'general-error'}). -xml(jingle_reason_gone, #elem{name = <<"gone">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'gone'}). -xml(jingle_reason_incompatible_parameters, #elem{name = <<"incompatible-parameters">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'incompatible-parameters'}). -xml(jingle_reason_media_error, #elem{name = <<"media-error">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'media-error'}). -xml(jingle_reason_security_error, #elem{name = <<"security-error">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'security-error'}). -xml(jingle_reason_success, #elem{name = <<"success">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'success'}). -xml(jingle_reason_timeout, #elem{name = <<"timeout">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'timeout'}). -xml(jingle_reason_unsupported_applications, #elem{name = <<"unsupported-applications">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'unsupported-applications'}). -xml(jingle_reason_unsupported_transports, #elem{name = <<"unsupported-transports">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = 'unsupported-transports'}). -xml(jingle_reason_text, #elem{name = <<"text">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(jingle_reason, #elem{name = <<"reason">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = {jingle_reason, '$reason', '$text', '$_els'}, refs = [#ref{name = jingle_reason_text, label = '$text'}, #ref{name = jingle_reason_alternative_session, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_busy, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_cancel, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_connectivity_error, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_decline, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_expired, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_failed_application, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_failed_transport, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_general_error, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_gone, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_incompatible_parameters, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_media_error, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_security_error, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_success, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_timeout, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_unsupported_applications, min = 0, max = 1, label = '$reason'}, #ref{name = jingle_reason_unsupported_transports, min = 0, max = 1, label = '$reason'}]}). -xml(jingle_content, #elem{name = <<"content">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = {jingle_content, '$creator', '$disposition', '$name', '$senders', '$_els'}, attrs = [#attr{name = <<"creator">>, required = true, enc = {enc_enum, []}, dec = {dec_enum, [[initiator, responder]]}}, #attr{name = <<"disposition">>}, #attr{name = <<"name">>, required = true}, #attr{name = <<"senders">>, enc = {enc_enum, []}, dec = {dec_enum, [[both, initiator, none, responder]]}, default = both}]}). -xml(jingle, #elem{name = <<"jingle">>, xmlns = <<"urn:xmpp:jingle:1">>, module = 'xep0166', result = {jingle, '$action', '$sid', '$initiator', '$responder', '$content', '$reason', '$_els'}, attrs = [#attr{name = <<"action">>, required = true, enc = {enc_enum, []}, dec = {dec_enum, [['content-accept', 'content-add', 'content-modify', 'content-reject', 'content-remove', 'description-info', 'security-info', 'session-accept', 'session-info', 'session-initiate', 'session-terminate', 'transport-accept', 'transport-info', 'transport-reject', 'transport-replace']]}}, #attr{name = <<"sid">>, required = true}, #attr{name = <<"initiator">>, enc = {jid, encode, []}, dec = {jid, decode, []}}, #attr{name = <<"responder">>, enc = {jid, encode, []}, dec = {jid, decode, []}}], refs = [#ref{name = jingle_content, label = '$content'}, #ref{name = jingle_reason, label = '$reason', min = 0, max = 1}]}). -xml(jingle_ft_date, #elem{name = <<"date">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', cdata = #cdata{required = true, enc = {enc_utc, []}, dec = {dec_utc, []}}, result = '$cdata'}). -xml(jingle_ft_desc, #elem{name = <<"desc">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', result = {text, '$lang', '$data'}, cdata = #cdata{label = '$data'}, attrs = [#attr{name = <<"xml:lang">>, dec = {xmpp_lang, check, []}, label = '$lang'}]}). -xml(jingle_ft_media_type, #elem{name = <<"media-type">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', cdata = #cdata{required = true}, result = '$cdata'}). -xml(jingle_ft_name, #elem{name = <<"name">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', cdata = #cdata{required = true}, result = '$cdata'}). -xml(jingle_ft_size, #elem{name = <<"size">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', cdata = #cdata{required = true, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, result = '$cdata'}). -xml(jingle_ft_range, #elem{name = <<"range">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', result = {jingle_ft_range, '$offset', '$length', '$hash'}, attrs = [#attr{name = <<"offset">>, default = 0, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}, #attr{name = <<"length">>, dec = {dec_int, [0, infinity]}, enc = {enc_int, []}}], refs = [#ref{name = hash, label = '$hash'}]}). -xml(jingle_ft_file, #elem{name = <<"file">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', result = {jingle_ft_file, '$date', '$desc', '$hash', '$hash-used', '$media-type', '$name', '$size', '$range'}, refs = [#ref{name = jingle_ft_date, label = '$date', max = 1}, #ref{name = jingle_ft_desc, label = '$desc'}, #ref{name = hash, label = '$hash'}, #ref{name = hash_used, label = '$hash-used', max = 1}, #ref{name = jingle_ft_media_type, label = '$media-type', max = 1}, #ref{name = jingle_ft_name, label = '$name', max = 1}, #ref{name = jingle_ft_size, label = '$size', max = 1}, #ref{name = jingle_ft_range, label = '$range', max = 1}]}). -xml(jingle_ft_description, #elem{name = <<"description">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', result = {jingle_ft_description, '$file'}, refs = [#ref{name = jingle_ft_file, label = '$file', min = 0, max = 1}]}). -xml(jingle_ft_received, #elem{name = <<"received">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', result = {jingle_ft_received, '$creator', '$name'}, attrs = [#attr{name = <<"creator">>, enc = {enc_enum, []}, dec = {dec_enum, [[initiator, responder]]}}, #attr{name = <<"name">>}]}). -xml(jingle_ft_checksum, #elem{name = <<"checksum">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:5">>, module = 'xep0234', result = {jingle_ft_checksum, '$creator', '$name', '$file'}, attrs = [#attr{name = <<"creator">>, enc = {enc_enum, []}, dec = {dec_enum, [[initiator, responder]]}}, #attr{name = <<"name">>}], refs = [#ref{name = jingle_ft_file, label = '$file', min = 1, max = 1}]}). -record(jingle_ft_error, {reason :: 'file-not-available' | 'file-too-large'}). -type jingle_ft_error() :: #jingle_ft_error{}. -xml(jingle_ft_error_file_not_available, #elem{name = <<"file-not-available">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, module = 'xep0234', result = {jingle_ft_error, 'file-not-available'}}). -xml(jingle_ft_error_file_too_large, #elem{name = <<"file-too-large">>, xmlns = <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, module = 'xep0234', result = {jingle_ft_error, 'file-too-large'}}). -xml(jingle_s5b_candidate_used, #elem{name = <<"candidate-used">>, xmlns = <<"urn:xmpp:jingle:transports:s5b:1">>, module = 'xep0260', result = '$cid', attrs = [#attr{name = <<"cid">>, required = true}]}). -xml(jingle_s5b_candidate, #elem{name = <<"candidate">>, xmlns = <<"urn:xmpp:jingle:transports:s5b:1">>, module = 'xep0260', result = {jingle_s5b_candidate, '$cid', '$host', '$port', '$jid', '$type', '$priority'}, attrs = [#attr{name = <<"cid">>, required = true}, #attr{name = <<"host">>, required = true, enc = {enc_ip, []}, dec = {dec_ip, []}}, #attr{name = <<"jid">>, required = true, enc = {jid, encode, []}, dec = {jid, decode, []}}, #attr{name = <<"port">>, enc = {enc_int, []}, dec = {dec_int, [0, 65535]}}, #attr{name = <<"priority">>, required = true, enc = {enc_int, []}, dec = {dec_int, [0, infinity]}}, #attr{name = <<"type">>, default = direct, enc = {enc_enum, []}, dec = {dec_enum, [[assisted, direct, proxy, tunnel]]}}]}). -xml(jingle_s5b_activated, #elem{name = <<"activated">>, xmlns = <<"urn:xmpp:jingle:transports:s5b:1">>, module = 'xep0260', result = '$cid', attrs = [#attr{name = <<"cid">>, required = true}]}). -xml(jingle_s5b_candidate_error, #elem{name = <<"candidate-error">>, xmlns = <<"urn:xmpp:jingle:transports:s5b:1">>, module = 'xep0260', result = 'candidate-error'}). -xml(jingle_s5b_proxy_error, #elem{name = <<"proxy-error">>, xmlns = <<"urn:xmpp:jingle:transports:s5b:1">>, module = 'xep0260', result = 'proxy-error'}). -xml(jingle_s5b_transport, #elem{name = <<"transport">>, xmlns = <<"urn:xmpp:jingle:transports:s5b:1">>, module = 'xep0260', result = {jingle_s5b_transport, '$sid', '$dstaddr', '$mode', '$candidates', '$candidate-used', '$activated', '$error'}, attrs = [#attr{name = <<"sid">>, required = true}, #attr{name = <<"dstaddr">>}, #attr{name = <<"mode">>, default = tcp, enc = {enc_enum, []}, dec = {dec_enum, [[tcp, udp]]}}], refs = [#ref{name = jingle_s5b_candidate, label = '$candidates'}, #ref{name = jingle_s5b_candidate_used, label = '$candidate-used', max = 1}, #ref{name = jingle_s5b_activated, label = '$activated', max = 1}, #ref{name = jingle_s5b_candidate_error, label = '$error', max = 1}, #ref{name = jingle_s5b_proxy_error, label = '$error', max = 1}]}). -xml(jingle_ibb_transport, #elem{name = <<"transport">>, xmlns = <<"urn:xmpp:jingle:transports:ibb:1">>, module = 'xep0261', result = {jingle_ibb_transport, '$sid', '$block-size', '$stanza'}, attrs = [#attr{name = <<"sid">>, required = true}, #attr{name = <<"block-size">>, required = true, enc = {enc_int, []}, dec = {dec_int, [0, infinity]}}, #attr{name = <<"stanza">>, default = iq, enc = {enc_enum, []}, dec = {dec_enum, [[iq, message]]}}]}). -xml(x509_cert, #elem{name = <<"x509-cert">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = '$cdata', cdata = #cdata{required = true, enc = {base64, encode, []}, dec = {base64, decode, []}}}). -xml(x509_csr, #elem{name = <<"x509-csr">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_csr, '$name', '$der'}, attrs = [#attr{name = <<"name">>}], cdata = #cdata{required = true, label = '$der', enc = {base64, encode, []}, dec = {base64, decode, []}}}). -xml(x509_cert_chain, #elem{name = <<"x509-cert-chain">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_cert_chain, '$name', '$certs'}, attrs = [#attr{name = <<"name">>}], refs = [#ref{name = x509_cert, label = '$certs'}]}). -xml(x509_ca_list, #elem{name = <<"x509-ca-list">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_ca_list, '$certs'}, refs = [#ref{name = x509_cert, label = '$certs'}]}). -xml(x509_signature, #elem{name = <<"x509-signature">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = '$cdata', cdata = #cdata{required = true, enc = {base64, encode, []}, dec = {base64, decode, []}}}). -xml(x509_request, #elem{name = <<"x509-request">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_request, '$transaction', '$csr', '$cert', '$signature'}, attrs = [#attr{name = <<"transaction">>, required = true}], refs = [#ref{name = x509_csr, label = '$csr', min = 1, max = 1}, #ref{name = x509_cert, label = '$cert', max = 1}, #ref{name = x509_signature, label = '$signature', max = 1}]}). -xml(x509_revoke, #elem{name = <<"x509-revoke">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_revoke, '$cert', '$signature'}, refs = [#ref{name = x509_cert, label = '$cert', min = 1, max = 1}, #ref{name = x509_signature, label = '$signature', min = 1, max = 1}]}). -xml(x509_challenge, #elem{name = <<"x509-challenge">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_challenge, '$transaction', '$uri', '$signature'}, attrs = [#attr{name = <<"transaction">>, required = true}, #attr{name = <<"uri">>, required = true}], refs = [#ref{name = x509_signature, label = '$signature', min = 1, max = 1}]}). -xml(x509_challenge_failed, #elem{name = <<"x509-challenge-failed">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_challenge_failed}}). -xml(x509_register, #elem{name = <<"x509-register">>, xmlns = <<"urn:xmpp:x509:0">>, module = 'xep0417', result = {x509_register}}). -spec dec_tzo(_) -> {integer(), integer()}. dec_tzo(Val) -> [H1, M1] = binary:split(Val, <<":">>), H = binary_to_integer(H1), M = binary_to_integer(M1), if H >= -12, H =< 12, M >= 0, M < 60 -> {H, M} end. enc_tzo({H, M}) -> Sign = if H >= 0 -> <<>>; true -> <<"-">> end, list_to_binary([Sign, io_lib:format("~2..0w:~2..0w", [abs(H), M])]). -spec dec_utc(_) -> erlang:timestamp(). dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). -spec jid:decode(_) -> jid:jid(). -spec check_resource(_) -> binary(). check_resource(R) -> case jid:resourceprep(R) of error -> erlang:error(badarg); _ -> R end. -spec nameprep(_) -> binary(). nameprep(S) -> case jid:nameprep(S) of error -> erlang:error(badarg); S1 -> S1 end. -spec nodeprep(_) -> binary(). nodeprep(S) -> case jid:nodeprep(S) of error -> erlang:error(badarg); S1 -> S1 end. -spec dec_bool(_) -> boolean(). dec_bool(<<"false">>) -> false; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"1">>) -> true. enc_bool(false) -> <<"false">>; enc_bool(true) -> <<"true">>. join([], _Sep) -> <<>>; join([H | T], Sep) -> <> || X <- T >>)/binary>>. -spec dec_ip(_) -> inet:ip_address(). dec_ip(S) -> {ok, Addr} = inet_parse:address(binary_to_list(S)), Addr. enc_ip({0,0,0,0,0,16#ffff,A,B}) -> enc_ip({(A bsr 8) band 16#ff, A band 16#ff, (B bsr 8) band 16#ff, B band 16#ff}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). -spec re:split(_, _) -> [binary()]. -spec base64:decode(_) -> binary(). -spec base64:mime_decode(_) -> binary(). -spec xmpp_lang:check(_) -> binary(). -type xmpp_host() :: binary() | inet:ip_address() | {binary() | inet:ip_address(), inet:port_number()}. -spec dec_host_port(_) -> binary() | inet:ip_address() | {binary() | inet:ip_address(), inet:port_number()}. dec_host_port(<<$[, T/binary>>) -> [IP, <<$:, Port/binary>>] = binary:split(T, <<$]>>), {dec_ip(IP), dec_int(Port, 0, 65535)}; dec_host_port(S) -> case binary:split(S, <<$:>>) of [S] -> try dec_ip(S) catch _:_ -> S end; [S, P] -> {try dec_ip(S) catch _:_ -> S end, dec_int(P, 0, 65535)} end. enc_host_port(Host) when is_binary(Host) -> Host; enc_host_port({Addr, Port}) when is_tuple(Addr) -> enc_host_port({enc_host_port(Addr), Port}); enc_host_port({Host, Port}) -> <>; enc_host_port({_,_,_,_} = IPv4) -> enc_ip(IPv4); enc_host_port({0,0,0,0,0,16#ffff,_,_} = IP) -> enc_ip(IP); enc_host_port({_,_,_,_,_,_,_,_} = IPv6) -> <<$[, (enc_ip(IPv6))/binary, $]>>. -spec dec_version(_) -> {non_neg_integer(), non_neg_integer()}. dec_version(S) -> [Major, Minor] = binary:split(S, <<$.>>), {binary_to_integer(Major), binary_to_integer(Minor)}. enc_version({Maj, Min}) -> <<(integer_to_binary(Maj))/binary, $., (integer_to_binary(Min))/binary>>. -spec dec_ps_aff(_) -> member | none | outcast | owner | publisher | publish_only. dec_ps_aff(<<"member">>) -> member; dec_ps_aff(<<"none">>) -> none; dec_ps_aff(<<"outcast">>) -> outcast; dec_ps_aff(<<"owner">>) -> owner; dec_ps_aff(<<"publisher">>) -> publisher; dec_ps_aff(<<"publish-only">>) -> publish_only. enc_ps_aff(member) -> <<"member">>; enc_ps_aff(none) -> <<"none">>; enc_ps_aff(outcast) -> <<"outcast">>; enc_ps_aff(owner) -> <<"owner">>; enc_ps_aff(publisher) -> <<"publisher">>; enc_ps_aff(publish_only) -> <<"publish-only">>. -spec dec_message_type(_) -> chat | groupchat | headline | error | normal. dec_message_type(<<"chat">>) -> chat; dec_message_type(<<"groupchat">>) -> groupchat; dec_message_type(<<"headline">>) -> headline; dec_message_type(<<"error">>) -> error; dec_message_type(_) -> normal. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/pubsub_publish_options.xdata0000644000232200023220000000216613610066730022022 0ustar debalancedebalance http://jabber.org/protocol/pubsub#publish-options XEP-0060 Forms enabling publication with options; each field must specify whether it defines METADATA to be attached to the item, a per-item OVERRIDE of the node configuration, or a PRECONDITION to be checked against the node configuration. xmpp-1.4.4/specs/mam_query.xdata0000644000232200023220000000071613610066730017217 0ustar debalancedebalance urn:xmpp:mam:1 XEP-0313 Form to query message archives xmpp-1.4.4/specs/captcha_form.xdata0000644000232200023220000000332313610066730017643 0ustar debalancedebalance urn:xmpp:captcha XEP-0158 Forms enabling the use of CAPTCHAs. xmpp-1.4.4/specs/muc_roomconfig.cfg0000644000232200023220000000065413610066730017665 0ustar debalancedebalance[{prefix, <<"muc#roomconfig_">>}, {prefix, <<"muc#">>}, {decode, [{<<"muc#roomconfig_maxusers">>, {dec_enum_int, [[none], 0, infinity]}}, {<<"muc#roomconfig_pubsub">>, {xmpp_uri, check, []}}, {<<"muc#roomconfig_lang">>, {xmpp_lang, check, []}}, {<<"voice_request_min_interval">>, {dec_int, [0, infinity]}}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/pubsub_meta_data.cfg0000644000232200023220000000067713610066730020163 0ustar debalancedebalance[{prefix, <<"pubsub#">>}, {decode, [{<<"pubsub#num_subscribers">>, {dec_int, [0,infinity]}}, {<<"pubsub#max_items">>, {dec_int, [0,infinity]}}, {<<"pubsub#creation_date">>, {xmpp_util, decode_timestamp, []}}]}, {encode, [{<<"pubsub#creation_date">>, {xmpp_util, encode_timestamp, []}}]}, {specs, [{<<"pubsub#creation_date">>, "erlang:timestamp()"}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/push_summary.cfg0000644000232200023220000000032513610066730017406 0ustar debalancedebalance[{decode, [{<<"message-count">>, {dec_int, [0, infinity]}}, {<<"pending-subscription-count">>, {dec_int, [0, infinity]}}]}]. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/specs/muc_roominfo.xdata0000644000232200023220000000470613610066730017717 0ustar debalancedebalance http://jabber.org/protocol/muc#roominfo XEP-0045 Forms enabling the communication of extended service discovery information about a Multi-User Chat (MUC) room. xmpp-1.4.4/rebar.config.script0000644000232200023220000001303413610066730016642 0ustar debalancedebalance%%%---------------------------------------------------------------------- %%% File : rebar.config.script %%% Author : Mickael Remond %%% Purpose : Rebar build script. Compliant with rebar and rebar3. %%% Created : 24 Nov 2015 by Mickael Remond %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%---------------------------------------------------------------------- Cfg = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"])) of {ok, Terms} -> Terms; _Err -> [] end ++ [{cflags, "-g -O2 -Wall"}, {ldflags, ""}, {with_gcov, "false"}], {cflags, CfgCFlags} = lists:keyfind(cflags, 1, Cfg), {ldflags, CfgLDFlags} = lists:keyfind(ldflags, 1, Cfg), {with_gcov, CfgWithGCov} = lists:keyfind(with_gcov, 1, Cfg), SysVersion = lists:map(fun erlang:list_to_integer/1, string:tokens(erlang:system_info(version), ".")), IsRebar3 = case application:get_key(rebar, vsn) of {ok, VSN} -> [VSN1 | _] = string:tokens(VSN, "-"), [Maj|_] = string:tokens(VSN1, "."), (list_to_integer(Maj) >= 3); undefined -> lists:keymember(mix, 1, application:loaded_applications()) end, JobId = case os:getenv("TRAVIS_JOB_ID") of false -> ""; V -> V end, ModCfg0 = fun(F, Cfg, [Key|Tail], Op, Default) -> {OldVal,PartCfg} = case lists:keytake(Key, 1, Cfg) of {value, {_, V1}, V2} -> {V1, V2}; false -> {if Tail == [] -> Default; true -> [] end, Cfg} end, case Tail of [] -> [{Key, Op(OldVal)} | PartCfg]; _ -> [{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg] end end, ModCfg = fun(Cfg, Keys, Op, Default) -> ModCfg0(ModCfg0, Cfg, Keys, Op, Default) end, ModCfgS = fun(Cfg, Keys, Val) -> ModCfg0(ModCfg0, Cfg, Keys, fun(_V) -> Val end, "") end, FilterConfig = fun(F, Cfg, [{Path, true, ModFun, Default} | Tail]) -> F(F, ModCfg0(ModCfg0, Cfg, Path, ModFun, Default), Tail); (F, Cfg, [_ | Tail]) -> F(F, Cfg, Tail); (F, Cfg, []) -> Cfg end, AppendStr = fun(Append) -> fun("") -> Append; (Val) -> Val ++ " " ++ Append end end, AppendList = fun(Append) -> fun(Val) -> Val ++ Append end end, Rebar3DepsFilter = fun(DepsList) -> lists:map(fun({DepName,_, {git,_, {tag,Version}}}) -> {DepName, Version}; (Dep) -> Dep end, DepsList) end, GlobalDepsFilter = fun(Deps) -> DepNames = lists:map(fun({DepName, _, _}) -> DepName; ({DepName, _}) -> DepName end, Deps), lists:filtermap(fun(Dep) -> case code:lib_dir(Dep) of {error, _} -> {true,"Unable to locate dep '"++atom_to_list(Dep)++"' in system deps."}; _ -> false end end, DepNames) end, ResolveDepPath = case IsRebar3 of true -> fun("deps/" ++ Rest) -> Slash = string:str(Rest, "/"), "_build/default/lib/" ++ string:sub_string(Rest, 1, Slash - 1) ++ string:sub_string(Rest, Slash); (Path) -> Path end; _ -> fun(P) -> P end end, ProcessErlOpt = fun(Vals) -> lists:map( fun({i, Path}) -> {i, ResolveDepPath(Path)}; (ErlOpt) -> ErlOpt end, Vals) end, Rules = [ {[port_env, "CFLAGS"], SysVersion >= [7, 3], AppendStr("-DHAS_ERTS_EXIT"), "$CFLAGS"}, {[port_env, "CFLAGS"], true, AppendStr(CfgCFlags), "$CFLAGS"}, {[port_env, "LDFLAGS"], true, AppendStr(CfgLDFlags), "$LDFLAGS"}, {[post_hooks], CfgWithGCov == "true", AppendList([{eunit, "gcov -o c_src jid"}, {eunit, "mv *.gcov .eunit/"}]), []}, {[port_env, "LDFLAGS"], CfgWithGCov == "true", AppendStr("--coverage"), ""}, {[port_env, "CFLAGS"], CfgWithGCov == "true", AppendStr("--coverage"), ""}, {[deps], IsRebar3, Rebar3DepsFilter, []}, {[plugins], IsRebar3, AppendList([rebar3_hex, pc, provider_asn1]), []}, {[provider_hooks], IsRebar3, AppendList([{pre, [ {compile, {pc, compile}}, {clean, {pc, clean}}, {compile, {asn, compile}}, {clean, {asn, clean}} ]}]), []}, {[deps], os:getenv("TRAVIS") == "true", AppendList([{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}]), []}, {[post_hooks], os:getenv("TRAVIS") == "true", AppendList([{eunit, "echo '\n%%! -pa .eunit/ deps/coveralls/ebin\nmain(_)->{ok,F}=file:open(\"erlang.json\",[write]),io:fwrite(F,\"~s\",[coveralls:convert_file(\".eunit/cover.coverdata\", \""++JobId++"\", \"travis-ci\",\"\")]).' > getcover.erl"}, {eunit, "escript ./getcover.erl"}]), []}, {[deps], os:getenv("USE_GLOBAL_DEPS") /= false, GlobalDepsFilter, []}, {[erl_opts], true, ProcessErlOpt, []} ], Config = FilterConfig(FilterConfig, CONFIG, Rules), %io:format("Rules:~n~p~n~nCONFIG:~n~p~n~nConfig:~n~p~n", [Rules, CONFIG, Config]), Config. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/CHANGELOG.md0000644000232200023220000001630513610066730014672 0ustar debalancedebalance# Version 1.4.4 * Fix handling of infinity values in couple places * Declare namespace for "urn:xmpp:carbons:rules:0" # Version 1.4.3 * Updating fast_tls to version 1.1.3. * Updating stringprep to version 1.0.18. * Updating fast_xml to version 1.1.38. * Updating p1_utils to version 1.0.17. # Version 1.4.2 * Fix incorrect return type # Version 1.4.1 * Add support for jid-prep * Improve handling of IDNA # Version 1.4.0 * Updating fast_tls to version 1.1.2. * Updating fast_xml to version 1.1.37. * Updating stringprep to version 1.0.17. * Updating p1_utils to version 1.0.16. * Update type specs * Improve xdata compiler * Add support for CAPTCHA data forms (XEP-0158) * Accept certificates without XmppAddr fields * Improve xmpp\_socket:get\_peer\_certificate/2 * Update pubsub#metadata form # Version 1.3.4 * Updating ezlib to version 1.0.6. * Updating fast_tls to version 1.1.1. * Updating fast_xml to version 1.1.36. * Updating p1_utils to version 1.0.15. * Updating stringprep to version 1.0.16. # Version 1.3.3 * Allow muc_subscriber element to have jid or nick attribute * Add support for XEP-0417 * Add get_subtags/2 and try_subtags/2 # Version 1.3.2 * Release from correct branch # Version 1.3.1 * Updating ezlib to version 1.0.5. * Updating fast_tls to version 1.1.0. * Updating fast_xml to version 1.1.35. * Updating p1_utils to version 1.0.14. * Updating stringprep to version 1.0.15. * Add contribution guide * Encode by attribute in stanza\_error # Version 1.3.0 * Introduce 'ignore_unknown' xdata codec option * Add support for decoding language tags generated by Cisco Jabber * Add support for latest MIX version and MIX-PAM (XEP-0405) # Version 1.2.8 * Improve building with rebar3 and hex packaging # Version 1.2.7 * Add code required for proxy protocol support # Version 1.2.6 * Updating fast_tls to version 1.0.26. * Add support for XEP-0048 and XEP-0411 * Add logging of data transmited over xml sockets * Add functions for processing white space pings * Validate xml:lang values * Fix encoding of timestamp with negative TZ offsets # Version 1.2.5 * Update packaging for hex # Version 1.2.4 * Updating fast_xml to version 1.1.34. * Updating stringprep to version 1.0.14. * Updating p1_utils to version 1.0.13. * Updating fast_tls to version 1.0.25. # Version 1.2.3 * Updating fast_tls to version f36ea5b74526c2c1c9c38f8d473168d95804f59d. * Updating fast_xml to version 1.1.33. * Updating p1_utils to version 1.0.13. * Updating stringprep to version 1.0.13. * Added handling for xeps: 319, 047, 261, 260, 234, 300, 166 * Refactor of xmpp\_socket # Version 1.2.2 * Updating fast_xml to version 1.1.32. * Fix crash when trying to encode xmlcdata * Add missing files to hex package # Version 1.2.1 * Updating p1_utils to version 1.0.12. * Updating fast_xml to version 1.1.31. * Updating stringprep to version 1.0.12. # Version 1.2.0 * Support XEP-0377: Spam Reporting * New xmpp_lang module to validate language tags * Improve muc#roominfo and muc#roomconfig data forms * XEP-0363: support and tags * XEP-0363: data form support * Add more functions to format errors * Change arity of err_gone(), err_redirect() and serr_see_other_host() THIS CHANGE INTRODUCES API INCOMPATIBILITY: use xref to check the code * Support multiple namespaces for the same data form # Version 1.1.21 * Updating fast_xml to version 1.1.30. * Support urn:xmpp:push:summary * Add parent attribute in \ * Update supported XEP-0359 version to v0.3.0 # Version 1.1.20 * Updating fast_xml to version 1.1.29. * Updating p1_utils to version 1.0.11. * Updating stringprep to version 1.0.11. * Fix compilation with rebar3 * Add new namespace from XEP-0398 * Update for changes in fast\_xml * Make mk\_text() append original text # Version 1.1.19 * Updating fast_xml to version 1.1.28. # Version 1.1.18 * Updating fast_xml to version 1.1.27. * Don't treat xmpp: URI as valid # Version 1.1.17 * Register pubsub#multi-items feature and add pubsub#max_items field to meta-data * Mention try_subtag/2 in the README * Fix formatting in API.md * New function: xmpp:try_subtag/2 * Make pretty printer understand jid records * Support XEP-0184: Message Delivery Receipts * Improve pretty printer and sub-elements processing * Add PubSub error condition: 'precondition-not-met' * pubsub_publish_options.xdata: Reject 'secret' * Allow empty URIs in xmpp_uri:check/1 * Update muc#roominfo form and add validation for 'muc#room*_pubsub' fields * Introduce xmpp_uri module # Version 1.1.16 * Updating fast_xml to version 1.1.25. * Add support for NS_MAM_2 * Improve handling of pubsub requests * Add supporgt for RFC 7622 * Allow multiple text element inside stanza/stream_error # Version 1.1.15 * Updating fast_xml to version 1.1.24. * Updating p1_utils to version 1.0.10. * Updating stringprep to version 1.0.10. * Compatibility with R19.3+ * XEP-0084 (User Avatar) support # Version 1.1.14 * Update hex packaging * Fix namespace in PubSub publishing options # Version 1.1.12 Holger Weiss: * Support XEP-0357: Push Notifications # Version 1.1.11 * Use fast_xml-1.1.23 * Use stringprep-1.0.9 # Version 1.1.10 Badlop: * Add jid support in muc_unsubscribe and muc_subscribe Evgeniy Khramtsov: * Add ?stanza_type, ?stanza_from and ?stanza_to macros * Remove unused p1_stream extension * Clarify the library's main idea Holger Weiss (4): * Encode/decode muc_unsubscribe JIDs * Add support for HTTP File Upload, version 0.3.0 * Makefile: Add dependencies for spec/xdata targets Paweł Chmielowski (3): * Add nif function jid:string_to_usr and use it * Fix return value from xmpp:start * Make multiple calls to jid:start() not generate nif reload error # Version 1.1.9 Evgeniy Khramtsov: * Deprecate jid:to_string/1 and jid:from_string/1 * Only check resource with stringprep * Improve type specs * Add documentation * Add set_tr_callback/2 function * Make it possible to uninstall translation callback * Use translation callback in data form encoders * Fix external codec registration for OTP 17 * Include compiler app when generating erlang.plt * Add notes about API instability # Version 1.1.8 Evgeniy Khramtsov: * Add get_meta/2 and get_meta/3 * Get rid of some dialyzer warnings # Version 1.1.7 Evgeniy Khramtsov: * Generate modular code for xmpp_codec * Improve type specs for set_from()/set_to() # Version 1.1.6 Evgeniy Khramtsov: * Add xmpp:serr_unsupported_feature() * Don't replace existing delay tag with the same 'from' # Version 1.1.5 Evgeniy Khramtsov: * Fix translation order * Add legacy auth stream feature support * Better support subtags with empty namespaces * Add dialback feature support * Fix error generation for raw xml elements * Treat unknown message type as "normal" * Allow including #text{} elements into #sm_failed{} * Add xmpp:del_meta/2 function * Fix typo in add_delay_info/4 * Make it possible to get text by lang * Don't crash if previous delay tag misses 'from' attribute # Version 1.1.4 * Support for password on MUC subcribe (Badlop) # Version 1.1.3 * Prepare release on hex.pm (Mickaël Rémond) * Add missing license (Mickaël Rémond) # Version 1.1.2 * Use fixed dependencies (Christophe Romain) # Version 1.1.1 * Work around Psi and 'jid-multi' field (Evgeniy Khramtsov) # Version 1.1.0 * Initial stable version (Evgeniy Khramtsov) xmpp-1.4.4/Makefile0000644000232200023220000000433513610066730014521 0ustar debalancedebalanceREBAR=./rebar ERL=erl all: src src: $(REBAR) get-deps compile spec: src/xmpp_codec.erl include/xmpp_codec.hrl deps/fast_xml/ebin/fxml_gen.beam $(ERL) -noinput +B -pa ebin -pa deps/*/ebin -eval \ 'case fxml_gen:compile("specs/xmpp_codec.spec", [{add_type_specs, xmpp_element}, {erl_dir, "src"}, {hrl_dir, "include"}]) of ok -> halt(0); _ -> halt(1) end.' xdata: ebin/xdata_codec.beam $(ERL) -noinput +B -pa ebin -pa deps/*/ebin -eval \ 'case xdata_codec:compile("specs", [{erl_dir, "src"}, {hrl_dir, "include"}]) of ok -> halt(0); _ -> halt(1) end.' clean: $(REBAR) clean rm -rf deps rm -rf ebin xref: all $(REBAR) skip_deps=true xref deps := $(wildcard deps/*/ebin) dialyzer/erlang.plt: @mkdir -p dialyzer @dialyzer --build_plt --output_plt dialyzer/erlang.plt \ -o dialyzer/erlang.log --apps kernel stdlib sasl erts syntax_tools compiler asn1 crypto; \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi dialyzer/deps.plt: @mkdir -p dialyzer @dialyzer --build_plt --output_plt dialyzer/deps.plt \ -o dialyzer/deps.log $(deps); \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi dialyzer/xmpp.plt: @mkdir -p dialyzer @dialyzer --build_plt --output_plt dialyzer/xmpp.plt \ -o dialyzer/xmpp.log ebin; \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi erlang_plt: dialyzer/erlang.plt @dialyzer --plt dialyzer/erlang.plt --check_plt -o dialyzer/erlang.log; \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi deps_plt: dialyzer/deps.plt @dialyzer --plt dialyzer/deps.plt --check_plt -o dialyzer/deps.log; \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi xmpp_plt: dialyzer/xmpp.plt @dialyzer --plt dialyzer/xmpp.plt --check_plt -o dialyzer/xmpp.log; \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi dialyzer: erlang_plt deps_plt xmpp_plt @dialyzer --plts dialyzer/*.plt --no_check_plt \ --get_warnings -o dialyzer/error.log ebin; \ status=$$? ; if [ $$status -ne 2 ]; then exit $$status; else exit 0; fi deps/fast_xml/ebin/fxml_gen.beam: $(REBAR) get-deps compile ebin/xdata_codec.beam: $(REBAR) get-deps compile .PHONY: clean src all spec xdata dialyzer erlang_plt deps_plt xmpp_plt xmpp-1.4.4/c_src/0000755000232200023220000000000013610066730014145 5ustar debalancedebalancexmpp-1.4.4/c_src/xmpp_uri.c0000644000232200023220000034301513610066730016162 0ustar debalancedebalance #line 1 "xmpp_uri.rl" #include #include #line 9 "xmpp_uri.rl" static const int xmpp_uri_start = 1; static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { return 0; } static ERL_NIF_TERM is_valid(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; int cs = 0, ret = 1; if (argc != 1) return enif_make_badarg(env); if (!(enif_inspect_binary(env, argv[0], &input))) return enif_make_badarg(env); if (!input.size) return enif_make_atom(env, "false"); char *p = (char *) input.data; char *pe = p + input.size; char *eof = pe; #line 37 "xmpp_uri.c" { cs = xmpp_uri_start; } #line 37 "xmpp_uri.rl" #line 44 "xmpp_uri.c" { if ( p == pe ) goto _test_eof; switch ( cs ) { case 1: switch( (*p) ) { case 88: goto st2; case 120: goto st2; } goto tr0; tr0: #line 7 "xmpp_uri.rl" { ret=0; } goto st0; #line 60 "xmpp_uri.c" st0: cs = 0; goto _out; st2: if ( ++p == pe ) goto _test_eof2; case 2: switch( (*p) ) { case 77: goto st3; case 109: goto st3; } goto tr0; st3: if ( ++p == pe ) goto _test_eof3; case 3: switch( (*p) ) { case 80: goto st4; case 112: goto st4; } goto tr0; st4: if ( ++p == pe ) goto _test_eof4; case 4: switch( (*p) ) { case 80: goto st5; case 112: goto st5; } goto tr0; st5: if ( ++p == pe ) goto _test_eof5; case 5: if ( (*p) == 58 ) goto st6; goto tr0; st6: if ( ++p == pe ) goto _test_eof6; case 6: switch( (*p) ) { case 33: goto st339; case 36: goto st339; case 37: goto st9; case 47: goto st176; case 59: goto st339; case 61: goto st339; case 64: goto st20; case 91: goto st21; case 95: goto st339; case 126: goto st339; } if ( (*p) < 40 ) { if ( 38 <= (*p) && (*p) <= 39 ) goto st341; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st339; } else if ( (*p) >= 65 ) goto st339; } else goto st339; goto tr0; st339: if ( ++p == pe ) goto _test_eof339; case 339: switch( (*p) ) { case 33: goto st339; case 35: goto st340; case 36: goto st339; case 37: goto st9; case 47: goto st342; case 59: goto st339; case 61: goto st339; case 63: goto st343; case 64: goto st20; case 95: goto st339; case 126: goto st339; } if ( (*p) < 40 ) { if ( 38 <= (*p) && (*p) <= 39 ) goto st341; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st339; } else if ( (*p) >= 65 ) goto st339; } else goto st339; goto tr0; st340: if ( ++p == pe ) goto _test_eof340; case 340: switch( (*p) ) { case 33: goto st340; case 37: goto st7; case 61: goto st340; case 95: goto st340; case 126: goto st340; } if ( (*p) < 63 ) { if ( 36 <= (*p) && (*p) <= 59 ) goto st340; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st340; } else goto st340; goto tr0; st7: if ( ++p == pe ) goto _test_eof7; case 7: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st8; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st8; } else goto st8; goto tr0; st8: if ( ++p == pe ) goto _test_eof8; case 8: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st340; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st340; } else goto st340; goto tr0; st9: if ( ++p == pe ) goto _test_eof9; case 9: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st10; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st10; } else goto st10; goto tr0; st10: if ( ++p == pe ) goto _test_eof10; case 10: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st339; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st339; } else goto st339; goto tr0; st341: if ( ++p == pe ) goto _test_eof341; case 341: switch( (*p) ) { case 33: goto st341; case 35: goto st340; case 37: goto st11; case 47: goto st342; case 59: goto st341; case 61: goto st341; case 63: goto st343; case 95: goto st341; case 126: goto st341; } if ( (*p) < 65 ) { if ( 36 <= (*p) && (*p) <= 57 ) goto st341; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st341; } else goto st341; goto tr0; st11: if ( ++p == pe ) goto _test_eof11; case 11: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st12; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st12; } else goto st12; goto tr0; st12: if ( ++p == pe ) goto _test_eof12; case 12: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st341; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st341; } else goto st341; goto tr0; st342: if ( ++p == pe ) goto _test_eof342; case 342: switch( (*p) ) { case 33: goto st342; case 35: goto st340; case 37: goto st13; case 61: goto st342; case 63: goto st343; case 95: goto st342; case 126: goto st342; } if ( (*p) < 48 ) { if ( 36 <= (*p) && (*p) <= 46 ) goto st342; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st342; } else if ( (*p) >= 65 ) goto st342; } else goto st342; goto tr0; st13: if ( ++p == pe ) goto _test_eof13; case 13: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st14; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st14; } else goto st14; goto tr0; st14: if ( ++p == pe ) goto _test_eof14; case 14: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st342; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st342; } else goto st342; goto tr0; st343: if ( ++p == pe ) goto _test_eof343; case 343: switch( (*p) ) { case 35: goto st340; case 37: goto st15; case 59: goto st17; case 95: goto st343; case 126: goto st343; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st343; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st343; } else if ( (*p) >= 65 ) goto st343; } else goto st343; goto tr0; st15: if ( ++p == pe ) goto _test_eof15; case 15: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st16; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st16; } else goto st16; goto tr0; st16: if ( ++p == pe ) goto _test_eof16; case 16: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st343; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st343; } else goto st343; goto tr0; st17: if ( ++p == pe ) goto _test_eof17; case 17: switch( (*p) ) { case 37: goto st18; case 61: goto st343; case 95: goto st17; case 126: goto st17; } if ( (*p) < 48 ) { if ( 45 <= (*p) && (*p) <= 46 ) goto st17; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st17; } else if ( (*p) >= 65 ) goto st17; } else goto st17; goto tr0; st18: if ( ++p == pe ) goto _test_eof18; case 18: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st19; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st19; } else goto st19; goto tr0; st19: if ( ++p == pe ) goto _test_eof19; case 19: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st17; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st17; } else goto st17; goto tr0; st20: if ( ++p == pe ) goto _test_eof20; case 20: switch( (*p) ) { case 33: goto st341; case 37: goto st11; case 59: goto st341; case 61: goto st341; case 91: goto st21; case 95: goto st341; case 126: goto st341; } if ( (*p) < 48 ) { if ( 36 <= (*p) && (*p) <= 46 ) goto st341; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st341; } else if ( (*p) >= 65 ) goto st341; } else goto st341; goto tr0; st21: if ( ++p == pe ) goto _test_eof21; case 21: switch( (*p) ) { case 58: goto st157; case 86: goto st172; case 118: goto st172; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st22; } else goto st22; goto tr0; st22: if ( ++p == pe ) goto _test_eof22; case 22: if ( (*p) == 58 ) goto st26; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st23; } else goto st23; goto tr0; st23: if ( ++p == pe ) goto _test_eof23; case 23: if ( (*p) == 58 ) goto st26; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st24; } else goto st24; goto tr0; st24: if ( ++p == pe ) goto _test_eof24; case 24: if ( (*p) == 58 ) goto st26; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st25; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st25; } else goto st25; goto tr0; st25: if ( ++p == pe ) goto _test_eof25; case 25: if ( (*p) == 58 ) goto st26; goto tr0; st26: if ( ++p == pe ) goto _test_eof26; case 26: if ( (*p) == 58 ) goto st143; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st27; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st27; } else goto st27; goto tr0; st27: if ( ++p == pe ) goto _test_eof27; case 27: if ( (*p) == 58 ) goto st31; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st28; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st28; } else goto st28; goto tr0; st28: if ( ++p == pe ) goto _test_eof28; case 28: if ( (*p) == 58 ) goto st31; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st29; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st29; } else goto st29; goto tr0; st29: if ( ++p == pe ) goto _test_eof29; case 29: if ( (*p) == 58 ) goto st31; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st30; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st30; } else goto st30; goto tr0; st30: if ( ++p == pe ) goto _test_eof30; case 30: if ( (*p) == 58 ) goto st31; goto tr0; st31: if ( ++p == pe ) goto _test_eof31; case 31: if ( (*p) == 58 ) goto st129; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st32; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st32; } else goto st32; goto tr0; st32: if ( ++p == pe ) goto _test_eof32; case 32: if ( (*p) == 58 ) goto st36; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st33; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st33; } else goto st33; goto tr0; st33: if ( ++p == pe ) goto _test_eof33; case 33: if ( (*p) == 58 ) goto st36; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st34; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st34; } else goto st34; goto tr0; st34: if ( ++p == pe ) goto _test_eof34; case 34: if ( (*p) == 58 ) goto st36; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st35; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st35; } else goto st35; goto tr0; st35: if ( ++p == pe ) goto _test_eof35; case 35: if ( (*p) == 58 ) goto st36; goto tr0; st36: if ( ++p == pe ) goto _test_eof36; case 36: if ( (*p) == 58 ) goto st115; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st37; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st37; } else goto st37; goto tr0; st37: if ( ++p == pe ) goto _test_eof37; case 37: if ( (*p) == 58 ) goto st41; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st38; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st38; } else goto st38; goto tr0; st38: if ( ++p == pe ) goto _test_eof38; case 38: if ( (*p) == 58 ) goto st41; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st39; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st39; } else goto st39; goto tr0; st39: if ( ++p == pe ) goto _test_eof39; case 39: if ( (*p) == 58 ) goto st41; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st40; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st40; } else goto st40; goto tr0; st40: if ( ++p == pe ) goto _test_eof40; case 40: if ( (*p) == 58 ) goto st41; goto tr0; st41: if ( ++p == pe ) goto _test_eof41; case 41: if ( (*p) == 58 ) goto st101; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st42; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st42; } else goto st42; goto tr0; st42: if ( ++p == pe ) goto _test_eof42; case 42: if ( (*p) == 58 ) goto st46; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st43; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st43; } else goto st43; goto tr0; st43: if ( ++p == pe ) goto _test_eof43; case 43: if ( (*p) == 58 ) goto st46; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st44; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st44; } else goto st44; goto tr0; st44: if ( ++p == pe ) goto _test_eof44; case 44: if ( (*p) == 58 ) goto st46; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st45; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st45; } else goto st45; goto tr0; st45: if ( ++p == pe ) goto _test_eof45; case 45: if ( (*p) == 58 ) goto st46; goto tr0; st46: if ( ++p == pe ) goto _test_eof46; case 46: if ( (*p) == 58 ) goto st87; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st47; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st47; } else goto st47; goto tr0; st47: if ( ++p == pe ) goto _test_eof47; case 47: if ( (*p) == 58 ) goto st51; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st48; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st48; } else goto st48; goto tr0; st48: if ( ++p == pe ) goto _test_eof48; case 48: if ( (*p) == 58 ) goto st51; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st49; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st49; } else goto st49; goto tr0; st49: if ( ++p == pe ) goto _test_eof49; case 49: if ( (*p) == 58 ) goto st51; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st50; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st50; } else goto st50; goto tr0; st50: if ( ++p == pe ) goto _test_eof50; case 50: if ( (*p) == 58 ) goto st51; goto tr0; st51: if ( ++p == pe ) goto _test_eof51; case 51: switch( (*p) ) { case 48: goto st52; case 49: goto st78; case 50: goto st81; case 58: goto st85; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st84; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st86; } else goto st86; goto tr0; st52: if ( ++p == pe ) goto _test_eof52; case 52: switch( (*p) ) { case 46: goto st53; case 58: goto st74; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st71; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st71; } else goto st71; goto tr0; st53: if ( ++p == pe ) goto _test_eof53; case 53: switch( (*p) ) { case 48: goto st54; case 49: goto st67; case 50: goto st69; } if ( 51 <= (*p) && (*p) <= 57 ) goto st68; goto tr0; st54: if ( ++p == pe ) goto _test_eof54; case 54: if ( (*p) == 46 ) goto st55; goto tr0; st55: if ( ++p == pe ) goto _test_eof55; case 55: switch( (*p) ) { case 48: goto st56; case 49: goto st63; case 50: goto st65; } if ( 51 <= (*p) && (*p) <= 57 ) goto st64; goto tr0; st56: if ( ++p == pe ) goto _test_eof56; case 56: if ( (*p) == 46 ) goto st57; goto tr0; st57: if ( ++p == pe ) goto _test_eof57; case 57: switch( (*p) ) { case 48: goto st58; case 49: goto st59; case 50: goto st61; } if ( 51 <= (*p) && (*p) <= 57 ) goto st60; goto tr0; st58: if ( ++p == pe ) goto _test_eof58; case 58: if ( (*p) == 93 ) goto st344; goto tr0; st344: if ( ++p == pe ) goto _test_eof344; case 344: switch( (*p) ) { case 35: goto st340; case 47: goto st342; case 63: goto st343; } goto tr0; st59: if ( ++p == pe ) goto _test_eof59; case 59: if ( (*p) == 93 ) goto st344; if ( 48 <= (*p) && (*p) <= 57 ) goto st60; goto tr0; st60: if ( ++p == pe ) goto _test_eof60; case 60: if ( (*p) == 93 ) goto st344; if ( 48 <= (*p) && (*p) <= 57 ) goto st58; goto tr0; st61: if ( ++p == pe ) goto _test_eof61; case 61: switch( (*p) ) { case 53: goto st62; case 93: goto st344; } if ( (*p) > 52 ) { if ( 54 <= (*p) && (*p) <= 57 ) goto st58; } else if ( (*p) >= 48 ) goto st60; goto tr0; st62: if ( ++p == pe ) goto _test_eof62; case 62: if ( (*p) == 93 ) goto st344; if ( 48 <= (*p) && (*p) <= 53 ) goto st58; goto tr0; st63: if ( ++p == pe ) goto _test_eof63; case 63: if ( (*p) == 46 ) goto st57; if ( 48 <= (*p) && (*p) <= 57 ) goto st64; goto tr0; st64: if ( ++p == pe ) goto _test_eof64; case 64: if ( (*p) == 46 ) goto st57; if ( 48 <= (*p) && (*p) <= 57 ) goto st56; goto tr0; st65: if ( ++p == pe ) goto _test_eof65; case 65: switch( (*p) ) { case 46: goto st57; case 53: goto st66; } if ( (*p) > 52 ) { if ( 54 <= (*p) && (*p) <= 57 ) goto st56; } else if ( (*p) >= 48 ) goto st64; goto tr0; st66: if ( ++p == pe ) goto _test_eof66; case 66: if ( (*p) == 46 ) goto st57; if ( 48 <= (*p) && (*p) <= 53 ) goto st56; goto tr0; st67: if ( ++p == pe ) goto _test_eof67; case 67: if ( (*p) == 46 ) goto st55; if ( 48 <= (*p) && (*p) <= 57 ) goto st68; goto tr0; st68: if ( ++p == pe ) goto _test_eof68; case 68: if ( (*p) == 46 ) goto st55; if ( 48 <= (*p) && (*p) <= 57 ) goto st54; goto tr0; st69: if ( ++p == pe ) goto _test_eof69; case 69: switch( (*p) ) { case 46: goto st55; case 53: goto st70; } if ( (*p) > 52 ) { if ( 54 <= (*p) && (*p) <= 57 ) goto st54; } else if ( (*p) >= 48 ) goto st68; goto tr0; st70: if ( ++p == pe ) goto _test_eof70; case 70: if ( (*p) == 46 ) goto st55; if ( 48 <= (*p) && (*p) <= 53 ) goto st54; goto tr0; st71: if ( ++p == pe ) goto _test_eof71; case 71: if ( (*p) == 58 ) goto st74; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st72; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st72; } else goto st72; goto tr0; st72: if ( ++p == pe ) goto _test_eof72; case 72: if ( (*p) == 58 ) goto st74; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st73; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st73; } else goto st73; goto tr0; st73: if ( ++p == pe ) goto _test_eof73; case 73: if ( (*p) == 58 ) goto st74; goto tr0; st74: if ( ++p == pe ) goto _test_eof74; case 74: if ( (*p) == 58 ) goto st58; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st75; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st75; } else goto st75; goto tr0; st75: if ( ++p == pe ) goto _test_eof75; case 75: if ( (*p) == 93 ) goto st344; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st76; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st76; } else goto st76; goto tr0; st76: if ( ++p == pe ) goto _test_eof76; case 76: if ( (*p) == 93 ) goto st344; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st77; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st77; } else goto st77; goto tr0; st77: if ( ++p == pe ) goto _test_eof77; case 77: if ( (*p) == 93 ) goto st344; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st58; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st58; } else goto st58; goto tr0; st78: if ( ++p == pe ) goto _test_eof78; case 78: switch( (*p) ) { case 46: goto st53; case 58: goto st74; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st79; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st71; } else goto st71; goto tr0; st79: if ( ++p == pe ) goto _test_eof79; case 79: switch( (*p) ) { case 46: goto st53; case 58: goto st74; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st80; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st72; } else goto st72; goto tr0; st80: if ( ++p == pe ) goto _test_eof80; case 80: switch( (*p) ) { case 46: goto st53; case 58: goto st74; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st73; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st73; } else goto st73; goto tr0; st81: if ( ++p == pe ) goto _test_eof81; case 81: switch( (*p) ) { case 46: goto st53; case 53: goto st82; case 58: goto st74; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st79; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st71; } else if ( (*p) >= 65 ) goto st71; } else goto st83; goto tr0; st82: if ( ++p == pe ) goto _test_eof82; case 82: switch( (*p) ) { case 46: goto st53; case 58: goto st74; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st80; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st72; } else if ( (*p) >= 65 ) goto st72; } else goto st72; goto tr0; st83: if ( ++p == pe ) goto _test_eof83; case 83: switch( (*p) ) { case 46: goto st53; case 58: goto st74; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st72; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st72; } else goto st72; goto tr0; st84: if ( ++p == pe ) goto _test_eof84; case 84: switch( (*p) ) { case 46: goto st53; case 58: goto st74; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st83; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st71; } else goto st71; goto tr0; st85: if ( ++p == pe ) goto _test_eof85; case 85: if ( (*p) == 93 ) goto st344; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st75; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st75; } else goto st75; goto tr0; st86: if ( ++p == pe ) goto _test_eof86; case 86: if ( (*p) == 58 ) goto st74; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st71; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st71; } else goto st71; goto tr0; st87: if ( ++p == pe ) goto _test_eof87; case 87: switch( (*p) ) { case 48: goto st88; case 49: goto st93; case 50: goto st96; case 93: goto st344; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st99; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st100; } else goto st100; goto tr0; st88: if ( ++p == pe ) goto _test_eof88; case 88: switch( (*p) ) { case 46: goto st53; case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st89; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st89; } else goto st89; goto tr0; st89: if ( ++p == pe ) goto _test_eof89; case 89: switch( (*p) ) { case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st90; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st90; } else goto st90; goto tr0; st90: if ( ++p == pe ) goto _test_eof90; case 90: switch( (*p) ) { case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st91; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st91; } else goto st91; goto tr0; st91: if ( ++p == pe ) goto _test_eof91; case 91: switch( (*p) ) { case 58: goto st92; case 93: goto st344; } goto tr0; st92: if ( ++p == pe ) goto _test_eof92; case 92: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st75; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st75; } else goto st75; goto tr0; st93: if ( ++p == pe ) goto _test_eof93; case 93: switch( (*p) ) { case 46: goto st53; case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st94; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st89; } else goto st89; goto tr0; st94: if ( ++p == pe ) goto _test_eof94; case 94: switch( (*p) ) { case 46: goto st53; case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st95; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st90; } else goto st90; goto tr0; st95: if ( ++p == pe ) goto _test_eof95; case 95: switch( (*p) ) { case 46: goto st53; case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st91; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st91; } else goto st91; goto tr0; st96: if ( ++p == pe ) goto _test_eof96; case 96: switch( (*p) ) { case 46: goto st53; case 53: goto st97; case 58: goto st92; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st94; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st89; } else if ( (*p) >= 65 ) goto st89; } else goto st98; goto tr0; st97: if ( ++p == pe ) goto _test_eof97; case 97: switch( (*p) ) { case 46: goto st53; case 58: goto st92; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st95; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st90; } else if ( (*p) >= 65 ) goto st90; } else goto st90; goto tr0; st98: if ( ++p == pe ) goto _test_eof98; case 98: switch( (*p) ) { case 46: goto st53; case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st90; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st90; } else goto st90; goto tr0; st99: if ( ++p == pe ) goto _test_eof99; case 99: switch( (*p) ) { case 46: goto st53; case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st98; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st89; } else goto st89; goto tr0; st100: if ( ++p == pe ) goto _test_eof100; case 100: switch( (*p) ) { case 58: goto st92; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st89; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st89; } else goto st89; goto tr0; st101: if ( ++p == pe ) goto _test_eof101; case 101: switch( (*p) ) { case 48: goto st102; case 49: goto st107; case 50: goto st110; case 93: goto st344; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st113; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st114; } else goto st114; goto tr0; st102: if ( ++p == pe ) goto _test_eof102; case 102: switch( (*p) ) { case 46: goto st53; case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st103; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st103; } else goto st103; goto tr0; st103: if ( ++p == pe ) goto _test_eof103; case 103: switch( (*p) ) { case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st104; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st104; } else goto st104; goto tr0; st104: if ( ++p == pe ) goto _test_eof104; case 104: switch( (*p) ) { case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st105; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st105; } else goto st105; goto tr0; st105: if ( ++p == pe ) goto _test_eof105; case 105: switch( (*p) ) { case 58: goto st106; case 93: goto st344; } goto tr0; st106: if ( ++p == pe ) goto _test_eof106; case 106: switch( (*p) ) { case 48: goto st88; case 49: goto st93; case 50: goto st96; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st99; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st100; } else goto st100; goto tr0; st107: if ( ++p == pe ) goto _test_eof107; case 107: switch( (*p) ) { case 46: goto st53; case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st108; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st103; } else goto st103; goto tr0; st108: if ( ++p == pe ) goto _test_eof108; case 108: switch( (*p) ) { case 46: goto st53; case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st109; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st104; } else goto st104; goto tr0; st109: if ( ++p == pe ) goto _test_eof109; case 109: switch( (*p) ) { case 46: goto st53; case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st105; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st105; } else goto st105; goto tr0; st110: if ( ++p == pe ) goto _test_eof110; case 110: switch( (*p) ) { case 46: goto st53; case 53: goto st111; case 58: goto st106; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st108; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st103; } else if ( (*p) >= 65 ) goto st103; } else goto st112; goto tr0; st111: if ( ++p == pe ) goto _test_eof111; case 111: switch( (*p) ) { case 46: goto st53; case 58: goto st106; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st109; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st104; } else if ( (*p) >= 65 ) goto st104; } else goto st104; goto tr0; st112: if ( ++p == pe ) goto _test_eof112; case 112: switch( (*p) ) { case 46: goto st53; case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st104; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st104; } else goto st104; goto tr0; st113: if ( ++p == pe ) goto _test_eof113; case 113: switch( (*p) ) { case 46: goto st53; case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st112; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st103; } else goto st103; goto tr0; st114: if ( ++p == pe ) goto _test_eof114; case 114: switch( (*p) ) { case 58: goto st106; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st103; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st103; } else goto st103; goto tr0; st115: if ( ++p == pe ) goto _test_eof115; case 115: switch( (*p) ) { case 48: goto st116; case 49: goto st121; case 50: goto st124; case 93: goto st344; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st127; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st128; } else goto st128; goto tr0; st116: if ( ++p == pe ) goto _test_eof116; case 116: switch( (*p) ) { case 46: goto st53; case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st117; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st117; } else goto st117; goto tr0; st117: if ( ++p == pe ) goto _test_eof117; case 117: switch( (*p) ) { case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st118; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st118; } else goto st118; goto tr0; st118: if ( ++p == pe ) goto _test_eof118; case 118: switch( (*p) ) { case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st119; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st119; } else goto st119; goto tr0; st119: if ( ++p == pe ) goto _test_eof119; case 119: switch( (*p) ) { case 58: goto st120; case 93: goto st344; } goto tr0; st120: if ( ++p == pe ) goto _test_eof120; case 120: switch( (*p) ) { case 48: goto st102; case 49: goto st107; case 50: goto st110; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st113; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st114; } else goto st114; goto tr0; st121: if ( ++p == pe ) goto _test_eof121; case 121: switch( (*p) ) { case 46: goto st53; case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st122; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st117; } else goto st117; goto tr0; st122: if ( ++p == pe ) goto _test_eof122; case 122: switch( (*p) ) { case 46: goto st53; case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st123; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st118; } else goto st118; goto tr0; st123: if ( ++p == pe ) goto _test_eof123; case 123: switch( (*p) ) { case 46: goto st53; case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st119; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st119; } else goto st119; goto tr0; st124: if ( ++p == pe ) goto _test_eof124; case 124: switch( (*p) ) { case 46: goto st53; case 53: goto st125; case 58: goto st120; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st122; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st117; } else if ( (*p) >= 65 ) goto st117; } else goto st126; goto tr0; st125: if ( ++p == pe ) goto _test_eof125; case 125: switch( (*p) ) { case 46: goto st53; case 58: goto st120; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st123; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st118; } else if ( (*p) >= 65 ) goto st118; } else goto st118; goto tr0; st126: if ( ++p == pe ) goto _test_eof126; case 126: switch( (*p) ) { case 46: goto st53; case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st118; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st118; } else goto st118; goto tr0; st127: if ( ++p == pe ) goto _test_eof127; case 127: switch( (*p) ) { case 46: goto st53; case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st126; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st117; } else goto st117; goto tr0; st128: if ( ++p == pe ) goto _test_eof128; case 128: switch( (*p) ) { case 58: goto st120; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st117; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st117; } else goto st117; goto tr0; st129: if ( ++p == pe ) goto _test_eof129; case 129: switch( (*p) ) { case 48: goto st130; case 49: goto st135; case 50: goto st138; case 93: goto st344; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st141; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st142; } else goto st142; goto tr0; st130: if ( ++p == pe ) goto _test_eof130; case 130: switch( (*p) ) { case 46: goto st53; case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st131; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st131; } else goto st131; goto tr0; st131: if ( ++p == pe ) goto _test_eof131; case 131: switch( (*p) ) { case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st132; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st132; } else goto st132; goto tr0; st132: if ( ++p == pe ) goto _test_eof132; case 132: switch( (*p) ) { case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st133; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st133; } else goto st133; goto tr0; st133: if ( ++p == pe ) goto _test_eof133; case 133: switch( (*p) ) { case 58: goto st134; case 93: goto st344; } goto tr0; st134: if ( ++p == pe ) goto _test_eof134; case 134: switch( (*p) ) { case 48: goto st116; case 49: goto st121; case 50: goto st124; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st127; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st128; } else goto st128; goto tr0; st135: if ( ++p == pe ) goto _test_eof135; case 135: switch( (*p) ) { case 46: goto st53; case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st136; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st131; } else goto st131; goto tr0; st136: if ( ++p == pe ) goto _test_eof136; case 136: switch( (*p) ) { case 46: goto st53; case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st137; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st132; } else goto st132; goto tr0; st137: if ( ++p == pe ) goto _test_eof137; case 137: switch( (*p) ) { case 46: goto st53; case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st133; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st133; } else goto st133; goto tr0; st138: if ( ++p == pe ) goto _test_eof138; case 138: switch( (*p) ) { case 46: goto st53; case 53: goto st139; case 58: goto st134; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st136; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st131; } else if ( (*p) >= 65 ) goto st131; } else goto st140; goto tr0; st139: if ( ++p == pe ) goto _test_eof139; case 139: switch( (*p) ) { case 46: goto st53; case 58: goto st134; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st137; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st132; } else if ( (*p) >= 65 ) goto st132; } else goto st132; goto tr0; st140: if ( ++p == pe ) goto _test_eof140; case 140: switch( (*p) ) { case 46: goto st53; case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st132; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st132; } else goto st132; goto tr0; st141: if ( ++p == pe ) goto _test_eof141; case 141: switch( (*p) ) { case 46: goto st53; case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st140; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st131; } else goto st131; goto tr0; st142: if ( ++p == pe ) goto _test_eof142; case 142: switch( (*p) ) { case 58: goto st134; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st131; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st131; } else goto st131; goto tr0; st143: if ( ++p == pe ) goto _test_eof143; case 143: switch( (*p) ) { case 48: goto st144; case 49: goto st149; case 50: goto st152; case 93: goto st344; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st155; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st156; } else goto st156; goto tr0; st144: if ( ++p == pe ) goto _test_eof144; case 144: switch( (*p) ) { case 46: goto st53; case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st145; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st145; } else goto st145; goto tr0; st145: if ( ++p == pe ) goto _test_eof145; case 145: switch( (*p) ) { case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st146; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st146; } else goto st146; goto tr0; st146: if ( ++p == pe ) goto _test_eof146; case 146: switch( (*p) ) { case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st147; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st147; } else goto st147; goto tr0; st147: if ( ++p == pe ) goto _test_eof147; case 147: switch( (*p) ) { case 58: goto st148; case 93: goto st344; } goto tr0; st148: if ( ++p == pe ) goto _test_eof148; case 148: switch( (*p) ) { case 48: goto st130; case 49: goto st135; case 50: goto st138; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st141; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st142; } else goto st142; goto tr0; st149: if ( ++p == pe ) goto _test_eof149; case 149: switch( (*p) ) { case 46: goto st53; case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st150; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st145; } else goto st145; goto tr0; st150: if ( ++p == pe ) goto _test_eof150; case 150: switch( (*p) ) { case 46: goto st53; case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st151; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st146; } else goto st146; goto tr0; st151: if ( ++p == pe ) goto _test_eof151; case 151: switch( (*p) ) { case 46: goto st53; case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st147; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st147; } else goto st147; goto tr0; st152: if ( ++p == pe ) goto _test_eof152; case 152: switch( (*p) ) { case 46: goto st53; case 53: goto st153; case 58: goto st148; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st150; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st145; } else if ( (*p) >= 65 ) goto st145; } else goto st154; goto tr0; st153: if ( ++p == pe ) goto _test_eof153; case 153: switch( (*p) ) { case 46: goto st53; case 58: goto st148; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st151; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st146; } else if ( (*p) >= 65 ) goto st146; } else goto st146; goto tr0; st154: if ( ++p == pe ) goto _test_eof154; case 154: switch( (*p) ) { case 46: goto st53; case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st146; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st146; } else goto st146; goto tr0; st155: if ( ++p == pe ) goto _test_eof155; case 155: switch( (*p) ) { case 46: goto st53; case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st154; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st145; } else goto st145; goto tr0; st156: if ( ++p == pe ) goto _test_eof156; case 156: switch( (*p) ) { case 58: goto st148; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st145; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st145; } else goto st145; goto tr0; st157: if ( ++p == pe ) goto _test_eof157; case 157: if ( (*p) == 58 ) goto st158; goto tr0; st158: if ( ++p == pe ) goto _test_eof158; case 158: switch( (*p) ) { case 48: goto st159; case 49: goto st164; case 50: goto st167; case 93: goto st344; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st170; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st171; } else goto st171; goto tr0; st159: if ( ++p == pe ) goto _test_eof159; case 159: switch( (*p) ) { case 46: goto st53; case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st160; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st160; } else goto st160; goto tr0; st160: if ( ++p == pe ) goto _test_eof160; case 160: switch( (*p) ) { case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st161; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st161; } else goto st161; goto tr0; st161: if ( ++p == pe ) goto _test_eof161; case 161: switch( (*p) ) { case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st162; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st162; } else goto st162; goto tr0; st162: if ( ++p == pe ) goto _test_eof162; case 162: switch( (*p) ) { case 58: goto st163; case 93: goto st344; } goto tr0; st163: if ( ++p == pe ) goto _test_eof163; case 163: switch( (*p) ) { case 48: goto st144; case 49: goto st149; case 50: goto st152; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st155; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st156; } else goto st156; goto tr0; st164: if ( ++p == pe ) goto _test_eof164; case 164: switch( (*p) ) { case 46: goto st53; case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st165; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st160; } else goto st160; goto tr0; st165: if ( ++p == pe ) goto _test_eof165; case 165: switch( (*p) ) { case 46: goto st53; case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st166; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st161; } else goto st161; goto tr0; st166: if ( ++p == pe ) goto _test_eof166; case 166: switch( (*p) ) { case 46: goto st53; case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st162; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st162; } else goto st162; goto tr0; st167: if ( ++p == pe ) goto _test_eof167; case 167: switch( (*p) ) { case 46: goto st53; case 53: goto st168; case 58: goto st163; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st165; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st160; } else if ( (*p) >= 65 ) goto st160; } else goto st169; goto tr0; st168: if ( ++p == pe ) goto _test_eof168; case 168: switch( (*p) ) { case 46: goto st53; case 58: goto st163; case 93: goto st344; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st166; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st161; } else if ( (*p) >= 65 ) goto st161; } else goto st161; goto tr0; st169: if ( ++p == pe ) goto _test_eof169; case 169: switch( (*p) ) { case 46: goto st53; case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st161; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st161; } else goto st161; goto tr0; st170: if ( ++p == pe ) goto _test_eof170; case 170: switch( (*p) ) { case 46: goto st53; case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st169; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st160; } else goto st160; goto tr0; st171: if ( ++p == pe ) goto _test_eof171; case 171: switch( (*p) ) { case 58: goto st163; case 93: goto st344; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st160; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st160; } else goto st160; goto tr0; st172: if ( ++p == pe ) goto _test_eof172; case 172: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st173; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st173; } else goto st173; goto tr0; st173: if ( ++p == pe ) goto _test_eof173; case 173: if ( (*p) == 46 ) goto st174; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st173; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st173; } else goto st173; goto tr0; st174: if ( ++p == pe ) goto _test_eof174; case 174: switch( (*p) ) { case 33: goto st175; case 36: goto st175; case 61: goto st175; case 95: goto st175; case 126: goto st175; } if ( (*p) < 48 ) { if ( 38 <= (*p) && (*p) <= 46 ) goto st175; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st175; } else if ( (*p) >= 65 ) goto st175; } else goto st175; goto tr0; st175: if ( ++p == pe ) goto _test_eof175; case 175: switch( (*p) ) { case 33: goto st175; case 36: goto st175; case 61: goto st175; case 93: goto st344; case 95: goto st175; case 126: goto st175; } if ( (*p) < 48 ) { if ( 38 <= (*p) && (*p) <= 46 ) goto st175; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st175; } else if ( (*p) >= 65 ) goto st175; } else goto st175; goto tr0; st176: if ( ++p == pe ) goto _test_eof176; case 176: if ( (*p) == 47 ) goto st177; goto tr0; st177: if ( ++p == pe ) goto _test_eof177; case 177: switch( (*p) ) { case 33: goto st177; case 36: goto st177; case 37: goto st178; case 59: goto st177; case 61: goto st177; case 64: goto st180; case 95: goto st177; case 126: goto st177; } if ( (*p) < 48 ) { if ( 40 <= (*p) && (*p) <= 46 ) goto st177; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st177; } else if ( (*p) >= 65 ) goto st177; } else goto st177; goto tr0; st178: if ( ++p == pe ) goto _test_eof178; case 178: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st179; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st179; } else goto st179; goto tr0; st179: if ( ++p == pe ) goto _test_eof179; case 179: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st177; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st177; } else goto st177; goto tr0; st180: if ( ++p == pe ) goto _test_eof180; case 180: switch( (*p) ) { case 33: goto st345; case 37: goto st181; case 59: goto st345; case 61: goto st345; case 91: goto st184; case 95: goto st345; case 126: goto st345; } if ( (*p) < 48 ) { if ( 36 <= (*p) && (*p) <= 46 ) goto st345; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st345; } else if ( (*p) >= 65 ) goto st345; } else goto st345; goto tr0; st345: if ( ++p == pe ) goto _test_eof345; case 345: switch( (*p) ) { case 33: goto st345; case 35: goto st340; case 37: goto st181; case 47: goto st183; case 59: goto st345; case 61: goto st345; case 63: goto st343; case 95: goto st345; case 126: goto st345; } if ( (*p) < 65 ) { if ( 36 <= (*p) && (*p) <= 57 ) goto st345; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st345; } else goto st345; goto tr0; st181: if ( ++p == pe ) goto _test_eof181; case 181: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st182; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st182; } else goto st182; goto tr0; st182: if ( ++p == pe ) goto _test_eof182; case 182: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st345; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st345; } else goto st345; goto tr0; st183: if ( ++p == pe ) goto _test_eof183; case 183: switch( (*p) ) { case 33: goto st339; case 36: goto st339; case 37: goto st9; case 59: goto st339; case 61: goto st339; case 64: goto st20; case 91: goto st21; case 95: goto st339; case 126: goto st339; } if ( (*p) < 48 ) { if ( (*p) > 39 ) { if ( 40 <= (*p) && (*p) <= 46 ) goto st339; } else if ( (*p) >= 38 ) goto st341; } else if ( (*p) > 57 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st339; } else if ( (*p) >= 65 ) goto st339; } else goto st339; goto tr0; st184: if ( ++p == pe ) goto _test_eof184; case 184: switch( (*p) ) { case 58: goto st320; case 86: goto st335; case 118: goto st335; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st185; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st185; } else goto st185; goto tr0; st185: if ( ++p == pe ) goto _test_eof185; case 185: if ( (*p) == 58 ) goto st189; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st186; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st186; } else goto st186; goto tr0; st186: if ( ++p == pe ) goto _test_eof186; case 186: if ( (*p) == 58 ) goto st189; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st187; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st187; } else goto st187; goto tr0; st187: if ( ++p == pe ) goto _test_eof187; case 187: if ( (*p) == 58 ) goto st189; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st188; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st188; } else goto st188; goto tr0; st188: if ( ++p == pe ) goto _test_eof188; case 188: if ( (*p) == 58 ) goto st189; goto tr0; st189: if ( ++p == pe ) goto _test_eof189; case 189: if ( (*p) == 58 ) goto st306; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st190; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st190; } else goto st190; goto tr0; st190: if ( ++p == pe ) goto _test_eof190; case 190: if ( (*p) == 58 ) goto st194; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st191; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st191; } else goto st191; goto tr0; st191: if ( ++p == pe ) goto _test_eof191; case 191: if ( (*p) == 58 ) goto st194; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st192; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st192; } else goto st192; goto tr0; st192: if ( ++p == pe ) goto _test_eof192; case 192: if ( (*p) == 58 ) goto st194; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st193; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st193; } else goto st193; goto tr0; st193: if ( ++p == pe ) goto _test_eof193; case 193: if ( (*p) == 58 ) goto st194; goto tr0; st194: if ( ++p == pe ) goto _test_eof194; case 194: if ( (*p) == 58 ) goto st292; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st195; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st195; } else goto st195; goto tr0; st195: if ( ++p == pe ) goto _test_eof195; case 195: if ( (*p) == 58 ) goto st199; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st196; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st196; } else goto st196; goto tr0; st196: if ( ++p == pe ) goto _test_eof196; case 196: if ( (*p) == 58 ) goto st199; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st197; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st197; } else goto st197; goto tr0; st197: if ( ++p == pe ) goto _test_eof197; case 197: if ( (*p) == 58 ) goto st199; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st198; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st198; } else goto st198; goto tr0; st198: if ( ++p == pe ) goto _test_eof198; case 198: if ( (*p) == 58 ) goto st199; goto tr0; st199: if ( ++p == pe ) goto _test_eof199; case 199: if ( (*p) == 58 ) goto st278; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st200; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st200; } else goto st200; goto tr0; st200: if ( ++p == pe ) goto _test_eof200; case 200: if ( (*p) == 58 ) goto st204; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st201; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st201; } else goto st201; goto tr0; st201: if ( ++p == pe ) goto _test_eof201; case 201: if ( (*p) == 58 ) goto st204; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st202; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st202; } else goto st202; goto tr0; st202: if ( ++p == pe ) goto _test_eof202; case 202: if ( (*p) == 58 ) goto st204; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st203; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st203; } else goto st203; goto tr0; st203: if ( ++p == pe ) goto _test_eof203; case 203: if ( (*p) == 58 ) goto st204; goto tr0; st204: if ( ++p == pe ) goto _test_eof204; case 204: if ( (*p) == 58 ) goto st264; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st205; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st205; } else goto st205; goto tr0; st205: if ( ++p == pe ) goto _test_eof205; case 205: if ( (*p) == 58 ) goto st209; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st206; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st206; } else goto st206; goto tr0; st206: if ( ++p == pe ) goto _test_eof206; case 206: if ( (*p) == 58 ) goto st209; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st207; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st207; } else goto st207; goto tr0; st207: if ( ++p == pe ) goto _test_eof207; case 207: if ( (*p) == 58 ) goto st209; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st208; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st208; } else goto st208; goto tr0; st208: if ( ++p == pe ) goto _test_eof208; case 208: if ( (*p) == 58 ) goto st209; goto tr0; st209: if ( ++p == pe ) goto _test_eof209; case 209: if ( (*p) == 58 ) goto st250; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st210; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st210; } else goto st210; goto tr0; st210: if ( ++p == pe ) goto _test_eof210; case 210: if ( (*p) == 58 ) goto st214; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st211; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st211; } else goto st211; goto tr0; st211: if ( ++p == pe ) goto _test_eof211; case 211: if ( (*p) == 58 ) goto st214; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st212; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st212; } else goto st212; goto tr0; st212: if ( ++p == pe ) goto _test_eof212; case 212: if ( (*p) == 58 ) goto st214; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st213; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st213; } else goto st213; goto tr0; st213: if ( ++p == pe ) goto _test_eof213; case 213: if ( (*p) == 58 ) goto st214; goto tr0; st214: if ( ++p == pe ) goto _test_eof214; case 214: switch( (*p) ) { case 48: goto st215; case 49: goto st241; case 50: goto st244; case 58: goto st248; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st247; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st249; } else goto st249; goto tr0; st215: if ( ++p == pe ) goto _test_eof215; case 215: switch( (*p) ) { case 46: goto st216; case 58: goto st237; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st234; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st234; } else goto st234; goto tr0; st216: if ( ++p == pe ) goto _test_eof216; case 216: switch( (*p) ) { case 48: goto st217; case 49: goto st230; case 50: goto st232; } if ( 51 <= (*p) && (*p) <= 57 ) goto st231; goto tr0; st217: if ( ++p == pe ) goto _test_eof217; case 217: if ( (*p) == 46 ) goto st218; goto tr0; st218: if ( ++p == pe ) goto _test_eof218; case 218: switch( (*p) ) { case 48: goto st219; case 49: goto st226; case 50: goto st228; } if ( 51 <= (*p) && (*p) <= 57 ) goto st227; goto tr0; st219: if ( ++p == pe ) goto _test_eof219; case 219: if ( (*p) == 46 ) goto st220; goto tr0; st220: if ( ++p == pe ) goto _test_eof220; case 220: switch( (*p) ) { case 48: goto st221; case 49: goto st222; case 50: goto st224; } if ( 51 <= (*p) && (*p) <= 57 ) goto st223; goto tr0; st221: if ( ++p == pe ) goto _test_eof221; case 221: if ( (*p) == 93 ) goto st346; goto tr0; st346: if ( ++p == pe ) goto _test_eof346; case 346: switch( (*p) ) { case 35: goto st340; case 47: goto st183; case 63: goto st343; } goto tr0; st222: if ( ++p == pe ) goto _test_eof222; case 222: if ( (*p) == 93 ) goto st346; if ( 48 <= (*p) && (*p) <= 57 ) goto st223; goto tr0; st223: if ( ++p == pe ) goto _test_eof223; case 223: if ( (*p) == 93 ) goto st346; if ( 48 <= (*p) && (*p) <= 57 ) goto st221; goto tr0; st224: if ( ++p == pe ) goto _test_eof224; case 224: switch( (*p) ) { case 53: goto st225; case 93: goto st346; } if ( (*p) > 52 ) { if ( 54 <= (*p) && (*p) <= 57 ) goto st221; } else if ( (*p) >= 48 ) goto st223; goto tr0; st225: if ( ++p == pe ) goto _test_eof225; case 225: if ( (*p) == 93 ) goto st346; if ( 48 <= (*p) && (*p) <= 53 ) goto st221; goto tr0; st226: if ( ++p == pe ) goto _test_eof226; case 226: if ( (*p) == 46 ) goto st220; if ( 48 <= (*p) && (*p) <= 57 ) goto st227; goto tr0; st227: if ( ++p == pe ) goto _test_eof227; case 227: if ( (*p) == 46 ) goto st220; if ( 48 <= (*p) && (*p) <= 57 ) goto st219; goto tr0; st228: if ( ++p == pe ) goto _test_eof228; case 228: switch( (*p) ) { case 46: goto st220; case 53: goto st229; } if ( (*p) > 52 ) { if ( 54 <= (*p) && (*p) <= 57 ) goto st219; } else if ( (*p) >= 48 ) goto st227; goto tr0; st229: if ( ++p == pe ) goto _test_eof229; case 229: if ( (*p) == 46 ) goto st220; if ( 48 <= (*p) && (*p) <= 53 ) goto st219; goto tr0; st230: if ( ++p == pe ) goto _test_eof230; case 230: if ( (*p) == 46 ) goto st218; if ( 48 <= (*p) && (*p) <= 57 ) goto st231; goto tr0; st231: if ( ++p == pe ) goto _test_eof231; case 231: if ( (*p) == 46 ) goto st218; if ( 48 <= (*p) && (*p) <= 57 ) goto st217; goto tr0; st232: if ( ++p == pe ) goto _test_eof232; case 232: switch( (*p) ) { case 46: goto st218; case 53: goto st233; } if ( (*p) > 52 ) { if ( 54 <= (*p) && (*p) <= 57 ) goto st217; } else if ( (*p) >= 48 ) goto st231; goto tr0; st233: if ( ++p == pe ) goto _test_eof233; case 233: if ( (*p) == 46 ) goto st218; if ( 48 <= (*p) && (*p) <= 53 ) goto st217; goto tr0; st234: if ( ++p == pe ) goto _test_eof234; case 234: if ( (*p) == 58 ) goto st237; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st235; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st235; } else goto st235; goto tr0; st235: if ( ++p == pe ) goto _test_eof235; case 235: if ( (*p) == 58 ) goto st237; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st236; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st236; } else goto st236; goto tr0; st236: if ( ++p == pe ) goto _test_eof236; case 236: if ( (*p) == 58 ) goto st237; goto tr0; st237: if ( ++p == pe ) goto _test_eof237; case 237: if ( (*p) == 58 ) goto st221; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st238; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st238; } else goto st238; goto tr0; st238: if ( ++p == pe ) goto _test_eof238; case 238: if ( (*p) == 93 ) goto st346; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st239; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st239; } else goto st239; goto tr0; st239: if ( ++p == pe ) goto _test_eof239; case 239: if ( (*p) == 93 ) goto st346; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st240; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st240; } else goto st240; goto tr0; st240: if ( ++p == pe ) goto _test_eof240; case 240: if ( (*p) == 93 ) goto st346; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st221; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st221; } else goto st221; goto tr0; st241: if ( ++p == pe ) goto _test_eof241; case 241: switch( (*p) ) { case 46: goto st216; case 58: goto st237; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st242; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st234; } else goto st234; goto tr0; st242: if ( ++p == pe ) goto _test_eof242; case 242: switch( (*p) ) { case 46: goto st216; case 58: goto st237; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st243; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st235; } else goto st235; goto tr0; st243: if ( ++p == pe ) goto _test_eof243; case 243: switch( (*p) ) { case 46: goto st216; case 58: goto st237; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st236; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st236; } else goto st236; goto tr0; st244: if ( ++p == pe ) goto _test_eof244; case 244: switch( (*p) ) { case 46: goto st216; case 53: goto st245; case 58: goto st237; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st242; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st234; } else if ( (*p) >= 65 ) goto st234; } else goto st246; goto tr0; st245: if ( ++p == pe ) goto _test_eof245; case 245: switch( (*p) ) { case 46: goto st216; case 58: goto st237; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st243; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st235; } else if ( (*p) >= 65 ) goto st235; } else goto st235; goto tr0; st246: if ( ++p == pe ) goto _test_eof246; case 246: switch( (*p) ) { case 46: goto st216; case 58: goto st237; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st235; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st235; } else goto st235; goto tr0; st247: if ( ++p == pe ) goto _test_eof247; case 247: switch( (*p) ) { case 46: goto st216; case 58: goto st237; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st246; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st234; } else goto st234; goto tr0; st248: if ( ++p == pe ) goto _test_eof248; case 248: if ( (*p) == 93 ) goto st346; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st238; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st238; } else goto st238; goto tr0; st249: if ( ++p == pe ) goto _test_eof249; case 249: if ( (*p) == 58 ) goto st237; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st234; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st234; } else goto st234; goto tr0; st250: if ( ++p == pe ) goto _test_eof250; case 250: switch( (*p) ) { case 48: goto st251; case 49: goto st256; case 50: goto st259; case 93: goto st346; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st262; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st263; } else goto st263; goto tr0; st251: if ( ++p == pe ) goto _test_eof251; case 251: switch( (*p) ) { case 46: goto st216; case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st252; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st252; } else goto st252; goto tr0; st252: if ( ++p == pe ) goto _test_eof252; case 252: switch( (*p) ) { case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st253; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st253; } else goto st253; goto tr0; st253: if ( ++p == pe ) goto _test_eof253; case 253: switch( (*p) ) { case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st254; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st254; } else goto st254; goto tr0; st254: if ( ++p == pe ) goto _test_eof254; case 254: switch( (*p) ) { case 58: goto st255; case 93: goto st346; } goto tr0; st255: if ( ++p == pe ) goto _test_eof255; case 255: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st238; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st238; } else goto st238; goto tr0; st256: if ( ++p == pe ) goto _test_eof256; case 256: switch( (*p) ) { case 46: goto st216; case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st257; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st252; } else goto st252; goto tr0; st257: if ( ++p == pe ) goto _test_eof257; case 257: switch( (*p) ) { case 46: goto st216; case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st258; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st253; } else goto st253; goto tr0; st258: if ( ++p == pe ) goto _test_eof258; case 258: switch( (*p) ) { case 46: goto st216; case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st254; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st254; } else goto st254; goto tr0; st259: if ( ++p == pe ) goto _test_eof259; case 259: switch( (*p) ) { case 46: goto st216; case 53: goto st260; case 58: goto st255; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st257; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st252; } else if ( (*p) >= 65 ) goto st252; } else goto st261; goto tr0; st260: if ( ++p == pe ) goto _test_eof260; case 260: switch( (*p) ) { case 46: goto st216; case 58: goto st255; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st258; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st253; } else if ( (*p) >= 65 ) goto st253; } else goto st253; goto tr0; st261: if ( ++p == pe ) goto _test_eof261; case 261: switch( (*p) ) { case 46: goto st216; case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st253; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st253; } else goto st253; goto tr0; st262: if ( ++p == pe ) goto _test_eof262; case 262: switch( (*p) ) { case 46: goto st216; case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st261; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st252; } else goto st252; goto tr0; st263: if ( ++p == pe ) goto _test_eof263; case 263: switch( (*p) ) { case 58: goto st255; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st252; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st252; } else goto st252; goto tr0; st264: if ( ++p == pe ) goto _test_eof264; case 264: switch( (*p) ) { case 48: goto st265; case 49: goto st270; case 50: goto st273; case 93: goto st346; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st276; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st277; } else goto st277; goto tr0; st265: if ( ++p == pe ) goto _test_eof265; case 265: switch( (*p) ) { case 46: goto st216; case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st266; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st266; } else goto st266; goto tr0; st266: if ( ++p == pe ) goto _test_eof266; case 266: switch( (*p) ) { case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st267; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st267; } else goto st267; goto tr0; st267: if ( ++p == pe ) goto _test_eof267; case 267: switch( (*p) ) { case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st268; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st268; } else goto st268; goto tr0; st268: if ( ++p == pe ) goto _test_eof268; case 268: switch( (*p) ) { case 58: goto st269; case 93: goto st346; } goto tr0; st269: if ( ++p == pe ) goto _test_eof269; case 269: switch( (*p) ) { case 48: goto st251; case 49: goto st256; case 50: goto st259; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st262; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st263; } else goto st263; goto tr0; st270: if ( ++p == pe ) goto _test_eof270; case 270: switch( (*p) ) { case 46: goto st216; case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st271; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st266; } else goto st266; goto tr0; st271: if ( ++p == pe ) goto _test_eof271; case 271: switch( (*p) ) { case 46: goto st216; case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st272; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st267; } else goto st267; goto tr0; st272: if ( ++p == pe ) goto _test_eof272; case 272: switch( (*p) ) { case 46: goto st216; case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st268; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st268; } else goto st268; goto tr0; st273: if ( ++p == pe ) goto _test_eof273; case 273: switch( (*p) ) { case 46: goto st216; case 53: goto st274; case 58: goto st269; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st271; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st266; } else if ( (*p) >= 65 ) goto st266; } else goto st275; goto tr0; st274: if ( ++p == pe ) goto _test_eof274; case 274: switch( (*p) ) { case 46: goto st216; case 58: goto st269; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st272; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st267; } else if ( (*p) >= 65 ) goto st267; } else goto st267; goto tr0; st275: if ( ++p == pe ) goto _test_eof275; case 275: switch( (*p) ) { case 46: goto st216; case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st267; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st267; } else goto st267; goto tr0; st276: if ( ++p == pe ) goto _test_eof276; case 276: switch( (*p) ) { case 46: goto st216; case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st275; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st266; } else goto st266; goto tr0; st277: if ( ++p == pe ) goto _test_eof277; case 277: switch( (*p) ) { case 58: goto st269; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st266; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st266; } else goto st266; goto tr0; st278: if ( ++p == pe ) goto _test_eof278; case 278: switch( (*p) ) { case 48: goto st279; case 49: goto st284; case 50: goto st287; case 93: goto st346; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st290; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st291; } else goto st291; goto tr0; st279: if ( ++p == pe ) goto _test_eof279; case 279: switch( (*p) ) { case 46: goto st216; case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st280; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st280; } else goto st280; goto tr0; st280: if ( ++p == pe ) goto _test_eof280; case 280: switch( (*p) ) { case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st281; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st281; } else goto st281; goto tr0; st281: if ( ++p == pe ) goto _test_eof281; case 281: switch( (*p) ) { case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st282; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st282; } else goto st282; goto tr0; st282: if ( ++p == pe ) goto _test_eof282; case 282: switch( (*p) ) { case 58: goto st283; case 93: goto st346; } goto tr0; st283: if ( ++p == pe ) goto _test_eof283; case 283: switch( (*p) ) { case 48: goto st265; case 49: goto st270; case 50: goto st273; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st276; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st277; } else goto st277; goto tr0; st284: if ( ++p == pe ) goto _test_eof284; case 284: switch( (*p) ) { case 46: goto st216; case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st285; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st280; } else goto st280; goto tr0; st285: if ( ++p == pe ) goto _test_eof285; case 285: switch( (*p) ) { case 46: goto st216; case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st286; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st281; } else goto st281; goto tr0; st286: if ( ++p == pe ) goto _test_eof286; case 286: switch( (*p) ) { case 46: goto st216; case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st282; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st282; } else goto st282; goto tr0; st287: if ( ++p == pe ) goto _test_eof287; case 287: switch( (*p) ) { case 46: goto st216; case 53: goto st288; case 58: goto st283; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st285; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st280; } else if ( (*p) >= 65 ) goto st280; } else goto st289; goto tr0; st288: if ( ++p == pe ) goto _test_eof288; case 288: switch( (*p) ) { case 46: goto st216; case 58: goto st283; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st286; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st281; } else if ( (*p) >= 65 ) goto st281; } else goto st281; goto tr0; st289: if ( ++p == pe ) goto _test_eof289; case 289: switch( (*p) ) { case 46: goto st216; case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st281; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st281; } else goto st281; goto tr0; st290: if ( ++p == pe ) goto _test_eof290; case 290: switch( (*p) ) { case 46: goto st216; case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st289; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st280; } else goto st280; goto tr0; st291: if ( ++p == pe ) goto _test_eof291; case 291: switch( (*p) ) { case 58: goto st283; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st280; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st280; } else goto st280; goto tr0; st292: if ( ++p == pe ) goto _test_eof292; case 292: switch( (*p) ) { case 48: goto st293; case 49: goto st298; case 50: goto st301; case 93: goto st346; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st304; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st305; } else goto st305; goto tr0; st293: if ( ++p == pe ) goto _test_eof293; case 293: switch( (*p) ) { case 46: goto st216; case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st294; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st294; } else goto st294; goto tr0; st294: if ( ++p == pe ) goto _test_eof294; case 294: switch( (*p) ) { case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st295; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st295; } else goto st295; goto tr0; st295: if ( ++p == pe ) goto _test_eof295; case 295: switch( (*p) ) { case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st296; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st296; } else goto st296; goto tr0; st296: if ( ++p == pe ) goto _test_eof296; case 296: switch( (*p) ) { case 58: goto st297; case 93: goto st346; } goto tr0; st297: if ( ++p == pe ) goto _test_eof297; case 297: switch( (*p) ) { case 48: goto st279; case 49: goto st284; case 50: goto st287; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st290; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st291; } else goto st291; goto tr0; st298: if ( ++p == pe ) goto _test_eof298; case 298: switch( (*p) ) { case 46: goto st216; case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st299; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st294; } else goto st294; goto tr0; st299: if ( ++p == pe ) goto _test_eof299; case 299: switch( (*p) ) { case 46: goto st216; case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st300; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st295; } else goto st295; goto tr0; st300: if ( ++p == pe ) goto _test_eof300; case 300: switch( (*p) ) { case 46: goto st216; case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st296; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st296; } else goto st296; goto tr0; st301: if ( ++p == pe ) goto _test_eof301; case 301: switch( (*p) ) { case 46: goto st216; case 53: goto st302; case 58: goto st297; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st299; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st294; } else if ( (*p) >= 65 ) goto st294; } else goto st303; goto tr0; st302: if ( ++p == pe ) goto _test_eof302; case 302: switch( (*p) ) { case 46: goto st216; case 58: goto st297; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st300; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st295; } else if ( (*p) >= 65 ) goto st295; } else goto st295; goto tr0; st303: if ( ++p == pe ) goto _test_eof303; case 303: switch( (*p) ) { case 46: goto st216; case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st295; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st295; } else goto st295; goto tr0; st304: if ( ++p == pe ) goto _test_eof304; case 304: switch( (*p) ) { case 46: goto st216; case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st303; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st294; } else goto st294; goto tr0; st305: if ( ++p == pe ) goto _test_eof305; case 305: switch( (*p) ) { case 58: goto st297; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st294; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st294; } else goto st294; goto tr0; st306: if ( ++p == pe ) goto _test_eof306; case 306: switch( (*p) ) { case 48: goto st307; case 49: goto st312; case 50: goto st315; case 93: goto st346; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st318; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st319; } else goto st319; goto tr0; st307: if ( ++p == pe ) goto _test_eof307; case 307: switch( (*p) ) { case 46: goto st216; case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st308; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st308; } else goto st308; goto tr0; st308: if ( ++p == pe ) goto _test_eof308; case 308: switch( (*p) ) { case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st309; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st309; } else goto st309; goto tr0; st309: if ( ++p == pe ) goto _test_eof309; case 309: switch( (*p) ) { case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st310; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st310; } else goto st310; goto tr0; st310: if ( ++p == pe ) goto _test_eof310; case 310: switch( (*p) ) { case 58: goto st311; case 93: goto st346; } goto tr0; st311: if ( ++p == pe ) goto _test_eof311; case 311: switch( (*p) ) { case 48: goto st293; case 49: goto st298; case 50: goto st301; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st304; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st305; } else goto st305; goto tr0; st312: if ( ++p == pe ) goto _test_eof312; case 312: switch( (*p) ) { case 46: goto st216; case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st313; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st308; } else goto st308; goto tr0; st313: if ( ++p == pe ) goto _test_eof313; case 313: switch( (*p) ) { case 46: goto st216; case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st314; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st309; } else goto st309; goto tr0; st314: if ( ++p == pe ) goto _test_eof314; case 314: switch( (*p) ) { case 46: goto st216; case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st310; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st310; } else goto st310; goto tr0; st315: if ( ++p == pe ) goto _test_eof315; case 315: switch( (*p) ) { case 46: goto st216; case 53: goto st316; case 58: goto st311; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st313; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st308; } else if ( (*p) >= 65 ) goto st308; } else goto st317; goto tr0; st316: if ( ++p == pe ) goto _test_eof316; case 316: switch( (*p) ) { case 46: goto st216; case 58: goto st311; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st314; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st309; } else if ( (*p) >= 65 ) goto st309; } else goto st309; goto tr0; st317: if ( ++p == pe ) goto _test_eof317; case 317: switch( (*p) ) { case 46: goto st216; case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st309; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st309; } else goto st309; goto tr0; st318: if ( ++p == pe ) goto _test_eof318; case 318: switch( (*p) ) { case 46: goto st216; case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st317; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st308; } else goto st308; goto tr0; st319: if ( ++p == pe ) goto _test_eof319; case 319: switch( (*p) ) { case 58: goto st311; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st308; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st308; } else goto st308; goto tr0; st320: if ( ++p == pe ) goto _test_eof320; case 320: if ( (*p) == 58 ) goto st321; goto tr0; st321: if ( ++p == pe ) goto _test_eof321; case 321: switch( (*p) ) { case 48: goto st322; case 49: goto st327; case 50: goto st330; case 93: goto st346; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st333; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st334; } else goto st334; goto tr0; st322: if ( ++p == pe ) goto _test_eof322; case 322: switch( (*p) ) { case 46: goto st216; case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st323; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st323; } else goto st323; goto tr0; st323: if ( ++p == pe ) goto _test_eof323; case 323: switch( (*p) ) { case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st324; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st324; } else goto st324; goto tr0; st324: if ( ++p == pe ) goto _test_eof324; case 324: switch( (*p) ) { case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st325; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st325; } else goto st325; goto tr0; st325: if ( ++p == pe ) goto _test_eof325; case 325: switch( (*p) ) { case 58: goto st326; case 93: goto st346; } goto tr0; st326: if ( ++p == pe ) goto _test_eof326; case 326: switch( (*p) ) { case 48: goto st307; case 49: goto st312; case 50: goto st315; } if ( (*p) < 65 ) { if ( 51 <= (*p) && (*p) <= 57 ) goto st318; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st319; } else goto st319; goto tr0; st327: if ( ++p == pe ) goto _test_eof327; case 327: switch( (*p) ) { case 46: goto st216; case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st328; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st323; } else goto st323; goto tr0; st328: if ( ++p == pe ) goto _test_eof328; case 328: switch( (*p) ) { case 46: goto st216; case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st329; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st324; } else goto st324; goto tr0; st329: if ( ++p == pe ) goto _test_eof329; case 329: switch( (*p) ) { case 46: goto st216; case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st325; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st325; } else goto st325; goto tr0; st330: if ( ++p == pe ) goto _test_eof330; case 330: switch( (*p) ) { case 46: goto st216; case 53: goto st331; case 58: goto st326; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 52 ) goto st328; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st323; } else if ( (*p) >= 65 ) goto st323; } else goto st332; goto tr0; st331: if ( ++p == pe ) goto _test_eof331; case 331: switch( (*p) ) { case 46: goto st216; case 58: goto st326; case 93: goto st346; } if ( (*p) < 54 ) { if ( 48 <= (*p) && (*p) <= 53 ) goto st329; } else if ( (*p) > 57 ) { if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st324; } else if ( (*p) >= 65 ) goto st324; } else goto st324; goto tr0; st332: if ( ++p == pe ) goto _test_eof332; case 332: switch( (*p) ) { case 46: goto st216; case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st324; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st324; } else goto st324; goto tr0; st333: if ( ++p == pe ) goto _test_eof333; case 333: switch( (*p) ) { case 46: goto st216; case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st332; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st323; } else goto st323; goto tr0; st334: if ( ++p == pe ) goto _test_eof334; case 334: switch( (*p) ) { case 58: goto st326; case 93: goto st346; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st323; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st323; } else goto st323; goto tr0; st335: if ( ++p == pe ) goto _test_eof335; case 335: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st336; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st336; } else goto st336; goto tr0; st336: if ( ++p == pe ) goto _test_eof336; case 336: if ( (*p) == 46 ) goto st337; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st336; } else if ( (*p) > 70 ) { if ( 97 <= (*p) && (*p) <= 102 ) goto st336; } else goto st336; goto tr0; st337: if ( ++p == pe ) goto _test_eof337; case 337: switch( (*p) ) { case 33: goto st338; case 36: goto st338; case 61: goto st338; case 95: goto st338; case 126: goto st338; } if ( (*p) < 48 ) { if ( 38 <= (*p) && (*p) <= 46 ) goto st338; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st338; } else if ( (*p) >= 65 ) goto st338; } else goto st338; goto tr0; st338: if ( ++p == pe ) goto _test_eof338; case 338: switch( (*p) ) { case 33: goto st338; case 36: goto st338; case 61: goto st338; case 93: goto st346; case 95: goto st338; case 126: goto st338; } if ( (*p) < 48 ) { if ( 38 <= (*p) && (*p) <= 46 ) goto st338; } else if ( (*p) > 59 ) { if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st338; } else if ( (*p) >= 65 ) goto st338; } else goto st338; goto tr0; } _test_eof2: cs = 2; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof339: cs = 339; goto _test_eof; _test_eof340: cs = 340; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; _test_eof10: cs = 10; goto _test_eof; _test_eof341: cs = 341; goto _test_eof; _test_eof11: cs = 11; goto _test_eof; _test_eof12: cs = 12; goto _test_eof; _test_eof342: cs = 342; goto _test_eof; _test_eof13: cs = 13; goto _test_eof; _test_eof14: cs = 14; goto _test_eof; _test_eof343: cs = 343; goto _test_eof; _test_eof15: cs = 15; goto _test_eof; _test_eof16: cs = 16; goto _test_eof; _test_eof17: cs = 17; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; _test_eof20: cs = 20; goto _test_eof; _test_eof21: cs = 21; goto _test_eof; _test_eof22: cs = 22; goto _test_eof; _test_eof23: cs = 23; goto _test_eof; _test_eof24: cs = 24; goto _test_eof; _test_eof25: cs = 25; goto _test_eof; _test_eof26: cs = 26; goto _test_eof; _test_eof27: cs = 27; goto _test_eof; _test_eof28: cs = 28; goto _test_eof; _test_eof29: cs = 29; goto _test_eof; _test_eof30: cs = 30; goto _test_eof; _test_eof31: cs = 31; goto _test_eof; _test_eof32: cs = 32; goto _test_eof; _test_eof33: cs = 33; goto _test_eof; _test_eof34: cs = 34; goto _test_eof; _test_eof35: cs = 35; goto _test_eof; _test_eof36: cs = 36; goto _test_eof; _test_eof37: cs = 37; goto _test_eof; _test_eof38: cs = 38; goto _test_eof; _test_eof39: cs = 39; goto _test_eof; _test_eof40: cs = 40; goto _test_eof; _test_eof41: cs = 41; goto _test_eof; _test_eof42: cs = 42; goto _test_eof; _test_eof43: cs = 43; goto _test_eof; _test_eof44: cs = 44; goto _test_eof; _test_eof45: cs = 45; goto _test_eof; _test_eof46: cs = 46; goto _test_eof; _test_eof47: cs = 47; goto _test_eof; _test_eof48: cs = 48; goto _test_eof; _test_eof49: cs = 49; goto _test_eof; _test_eof50: cs = 50; goto _test_eof; _test_eof51: cs = 51; goto _test_eof; _test_eof52: cs = 52; goto _test_eof; _test_eof53: cs = 53; goto _test_eof; _test_eof54: cs = 54; goto _test_eof; _test_eof55: cs = 55; goto _test_eof; _test_eof56: cs = 56; goto _test_eof; _test_eof57: cs = 57; goto _test_eof; _test_eof58: cs = 58; goto _test_eof; _test_eof344: cs = 344; goto _test_eof; _test_eof59: cs = 59; goto _test_eof; _test_eof60: cs = 60; goto _test_eof; _test_eof61: cs = 61; goto _test_eof; _test_eof62: cs = 62; goto _test_eof; _test_eof63: cs = 63; goto _test_eof; _test_eof64: cs = 64; goto _test_eof; _test_eof65: cs = 65; goto _test_eof; _test_eof66: cs = 66; goto _test_eof; _test_eof67: cs = 67; goto _test_eof; _test_eof68: cs = 68; goto _test_eof; _test_eof69: cs = 69; goto _test_eof; _test_eof70: cs = 70; goto _test_eof; _test_eof71: cs = 71; goto _test_eof; _test_eof72: cs = 72; goto _test_eof; _test_eof73: cs = 73; goto _test_eof; _test_eof74: cs = 74; goto _test_eof; _test_eof75: cs = 75; goto _test_eof; _test_eof76: cs = 76; goto _test_eof; _test_eof77: cs = 77; goto _test_eof; _test_eof78: cs = 78; goto _test_eof; _test_eof79: cs = 79; goto _test_eof; _test_eof80: cs = 80; goto _test_eof; _test_eof81: cs = 81; goto _test_eof; _test_eof82: cs = 82; goto _test_eof; _test_eof83: cs = 83; goto _test_eof; _test_eof84: cs = 84; goto _test_eof; _test_eof85: cs = 85; goto _test_eof; _test_eof86: cs = 86; goto _test_eof; _test_eof87: cs = 87; goto _test_eof; _test_eof88: cs = 88; goto _test_eof; _test_eof89: cs = 89; goto _test_eof; _test_eof90: cs = 90; goto _test_eof; _test_eof91: cs = 91; goto _test_eof; _test_eof92: cs = 92; goto _test_eof; _test_eof93: cs = 93; goto _test_eof; _test_eof94: cs = 94; goto _test_eof; _test_eof95: cs = 95; goto _test_eof; _test_eof96: cs = 96; goto _test_eof; _test_eof97: cs = 97; goto _test_eof; _test_eof98: cs = 98; goto _test_eof; _test_eof99: cs = 99; goto _test_eof; _test_eof100: cs = 100; goto _test_eof; _test_eof101: cs = 101; goto _test_eof; _test_eof102: cs = 102; goto _test_eof; _test_eof103: cs = 103; goto _test_eof; _test_eof104: cs = 104; goto _test_eof; _test_eof105: cs = 105; goto _test_eof; _test_eof106: cs = 106; goto _test_eof; _test_eof107: cs = 107; goto _test_eof; _test_eof108: cs = 108; goto _test_eof; _test_eof109: cs = 109; goto _test_eof; _test_eof110: cs = 110; goto _test_eof; _test_eof111: cs = 111; goto _test_eof; _test_eof112: cs = 112; goto _test_eof; _test_eof113: cs = 113; goto _test_eof; _test_eof114: cs = 114; goto _test_eof; _test_eof115: cs = 115; goto _test_eof; _test_eof116: cs = 116; goto _test_eof; _test_eof117: cs = 117; goto _test_eof; _test_eof118: cs = 118; goto _test_eof; _test_eof119: cs = 119; goto _test_eof; _test_eof120: cs = 120; goto _test_eof; _test_eof121: cs = 121; goto _test_eof; _test_eof122: cs = 122; goto _test_eof; _test_eof123: cs = 123; goto _test_eof; _test_eof124: cs = 124; goto _test_eof; _test_eof125: cs = 125; goto _test_eof; _test_eof126: cs = 126; goto _test_eof; _test_eof127: cs = 127; goto _test_eof; _test_eof128: cs = 128; goto _test_eof; _test_eof129: cs = 129; goto _test_eof; _test_eof130: cs = 130; goto _test_eof; _test_eof131: cs = 131; goto _test_eof; _test_eof132: cs = 132; goto _test_eof; _test_eof133: cs = 133; goto _test_eof; _test_eof134: cs = 134; goto _test_eof; _test_eof135: cs = 135; goto _test_eof; _test_eof136: cs = 136; goto _test_eof; _test_eof137: cs = 137; goto _test_eof; _test_eof138: cs = 138; goto _test_eof; _test_eof139: cs = 139; goto _test_eof; _test_eof140: cs = 140; goto _test_eof; _test_eof141: cs = 141; goto _test_eof; _test_eof142: cs = 142; goto _test_eof; _test_eof143: cs = 143; goto _test_eof; _test_eof144: cs = 144; goto _test_eof; _test_eof145: cs = 145; goto _test_eof; _test_eof146: cs = 146; goto _test_eof; _test_eof147: cs = 147; goto _test_eof; _test_eof148: cs = 148; goto _test_eof; _test_eof149: cs = 149; goto _test_eof; _test_eof150: cs = 150; goto _test_eof; _test_eof151: cs = 151; goto _test_eof; _test_eof152: cs = 152; goto _test_eof; _test_eof153: cs = 153; goto _test_eof; _test_eof154: cs = 154; goto _test_eof; _test_eof155: cs = 155; goto _test_eof; _test_eof156: cs = 156; goto _test_eof; _test_eof157: cs = 157; goto _test_eof; _test_eof158: cs = 158; goto _test_eof; _test_eof159: cs = 159; goto _test_eof; _test_eof160: cs = 160; goto _test_eof; _test_eof161: cs = 161; goto _test_eof; _test_eof162: cs = 162; goto _test_eof; _test_eof163: cs = 163; goto _test_eof; _test_eof164: cs = 164; goto _test_eof; _test_eof165: cs = 165; goto _test_eof; _test_eof166: cs = 166; goto _test_eof; _test_eof167: cs = 167; goto _test_eof; _test_eof168: cs = 168; goto _test_eof; _test_eof169: cs = 169; goto _test_eof; _test_eof170: cs = 170; goto _test_eof; _test_eof171: cs = 171; goto _test_eof; _test_eof172: cs = 172; goto _test_eof; _test_eof173: cs = 173; goto _test_eof; _test_eof174: cs = 174; goto _test_eof; _test_eof175: cs = 175; goto _test_eof; _test_eof176: cs = 176; goto _test_eof; _test_eof177: cs = 177; goto _test_eof; _test_eof178: cs = 178; goto _test_eof; _test_eof179: cs = 179; goto _test_eof; _test_eof180: cs = 180; goto _test_eof; _test_eof345: cs = 345; goto _test_eof; _test_eof181: cs = 181; goto _test_eof; _test_eof182: cs = 182; goto _test_eof; _test_eof183: cs = 183; goto _test_eof; _test_eof184: cs = 184; goto _test_eof; _test_eof185: cs = 185; goto _test_eof; _test_eof186: cs = 186; goto _test_eof; _test_eof187: cs = 187; goto _test_eof; _test_eof188: cs = 188; goto _test_eof; _test_eof189: cs = 189; goto _test_eof; _test_eof190: cs = 190; goto _test_eof; _test_eof191: cs = 191; goto _test_eof; _test_eof192: cs = 192; goto _test_eof; _test_eof193: cs = 193; goto _test_eof; _test_eof194: cs = 194; goto _test_eof; _test_eof195: cs = 195; goto _test_eof; _test_eof196: cs = 196; goto _test_eof; _test_eof197: cs = 197; goto _test_eof; _test_eof198: cs = 198; goto _test_eof; _test_eof199: cs = 199; goto _test_eof; _test_eof200: cs = 200; goto _test_eof; _test_eof201: cs = 201; goto _test_eof; _test_eof202: cs = 202; goto _test_eof; _test_eof203: cs = 203; goto _test_eof; _test_eof204: cs = 204; goto _test_eof; _test_eof205: cs = 205; goto _test_eof; _test_eof206: cs = 206; goto _test_eof; _test_eof207: cs = 207; goto _test_eof; _test_eof208: cs = 208; goto _test_eof; _test_eof209: cs = 209; goto _test_eof; _test_eof210: cs = 210; goto _test_eof; _test_eof211: cs = 211; goto _test_eof; _test_eof212: cs = 212; goto _test_eof; _test_eof213: cs = 213; goto _test_eof; _test_eof214: cs = 214; goto _test_eof; _test_eof215: cs = 215; goto _test_eof; _test_eof216: cs = 216; goto _test_eof; _test_eof217: cs = 217; goto _test_eof; _test_eof218: cs = 218; goto _test_eof; _test_eof219: cs = 219; goto _test_eof; _test_eof220: cs = 220; goto _test_eof; _test_eof221: cs = 221; goto _test_eof; _test_eof346: cs = 346; goto _test_eof; _test_eof222: cs = 222; goto _test_eof; _test_eof223: cs = 223; goto _test_eof; _test_eof224: cs = 224; goto _test_eof; _test_eof225: cs = 225; goto _test_eof; _test_eof226: cs = 226; goto _test_eof; _test_eof227: cs = 227; goto _test_eof; _test_eof228: cs = 228; goto _test_eof; _test_eof229: cs = 229; goto _test_eof; _test_eof230: cs = 230; goto _test_eof; _test_eof231: cs = 231; goto _test_eof; _test_eof232: cs = 232; goto _test_eof; _test_eof233: cs = 233; goto _test_eof; _test_eof234: cs = 234; goto _test_eof; _test_eof235: cs = 235; goto _test_eof; _test_eof236: cs = 236; goto _test_eof; _test_eof237: cs = 237; goto _test_eof; _test_eof238: cs = 238; goto _test_eof; _test_eof239: cs = 239; goto _test_eof; _test_eof240: cs = 240; goto _test_eof; _test_eof241: cs = 241; goto _test_eof; _test_eof242: cs = 242; goto _test_eof; _test_eof243: cs = 243; goto _test_eof; _test_eof244: cs = 244; goto _test_eof; _test_eof245: cs = 245; goto _test_eof; _test_eof246: cs = 246; goto _test_eof; _test_eof247: cs = 247; goto _test_eof; _test_eof248: cs = 248; goto _test_eof; _test_eof249: cs = 249; goto _test_eof; _test_eof250: cs = 250; goto _test_eof; _test_eof251: cs = 251; goto _test_eof; _test_eof252: cs = 252; goto _test_eof; _test_eof253: cs = 253; goto _test_eof; _test_eof254: cs = 254; goto _test_eof; _test_eof255: cs = 255; goto _test_eof; _test_eof256: cs = 256; goto _test_eof; _test_eof257: cs = 257; goto _test_eof; _test_eof258: cs = 258; goto _test_eof; _test_eof259: cs = 259; goto _test_eof; _test_eof260: cs = 260; goto _test_eof; _test_eof261: cs = 261; goto _test_eof; _test_eof262: cs = 262; goto _test_eof; _test_eof263: cs = 263; goto _test_eof; _test_eof264: cs = 264; goto _test_eof; _test_eof265: cs = 265; goto _test_eof; _test_eof266: cs = 266; goto _test_eof; _test_eof267: cs = 267; goto _test_eof; _test_eof268: cs = 268; goto _test_eof; _test_eof269: cs = 269; goto _test_eof; _test_eof270: cs = 270; goto _test_eof; _test_eof271: cs = 271; goto _test_eof; _test_eof272: cs = 272; goto _test_eof; _test_eof273: cs = 273; goto _test_eof; _test_eof274: cs = 274; goto _test_eof; _test_eof275: cs = 275; goto _test_eof; _test_eof276: cs = 276; goto _test_eof; _test_eof277: cs = 277; goto _test_eof; _test_eof278: cs = 278; goto _test_eof; _test_eof279: cs = 279; goto _test_eof; _test_eof280: cs = 280; goto _test_eof; _test_eof281: cs = 281; goto _test_eof; _test_eof282: cs = 282; goto _test_eof; _test_eof283: cs = 283; goto _test_eof; _test_eof284: cs = 284; goto _test_eof; _test_eof285: cs = 285; goto _test_eof; _test_eof286: cs = 286; goto _test_eof; _test_eof287: cs = 287; goto _test_eof; _test_eof288: cs = 288; goto _test_eof; _test_eof289: cs = 289; goto _test_eof; _test_eof290: cs = 290; goto _test_eof; _test_eof291: cs = 291; goto _test_eof; _test_eof292: cs = 292; goto _test_eof; _test_eof293: cs = 293; goto _test_eof; _test_eof294: cs = 294; goto _test_eof; _test_eof295: cs = 295; goto _test_eof; _test_eof296: cs = 296; goto _test_eof; _test_eof297: cs = 297; goto _test_eof; _test_eof298: cs = 298; goto _test_eof; _test_eof299: cs = 299; goto _test_eof; _test_eof300: cs = 300; goto _test_eof; _test_eof301: cs = 301; goto _test_eof; _test_eof302: cs = 302; goto _test_eof; _test_eof303: cs = 303; goto _test_eof; _test_eof304: cs = 304; goto _test_eof; _test_eof305: cs = 305; goto _test_eof; _test_eof306: cs = 306; goto _test_eof; _test_eof307: cs = 307; goto _test_eof; _test_eof308: cs = 308; goto _test_eof; _test_eof309: cs = 309; goto _test_eof; _test_eof310: cs = 310; goto _test_eof; _test_eof311: cs = 311; goto _test_eof; _test_eof312: cs = 312; goto _test_eof; _test_eof313: cs = 313; goto _test_eof; _test_eof314: cs = 314; goto _test_eof; _test_eof315: cs = 315; goto _test_eof; _test_eof316: cs = 316; goto _test_eof; _test_eof317: cs = 317; goto _test_eof; _test_eof318: cs = 318; goto _test_eof; _test_eof319: cs = 319; goto _test_eof; _test_eof320: cs = 320; goto _test_eof; _test_eof321: cs = 321; goto _test_eof; _test_eof322: cs = 322; goto _test_eof; _test_eof323: cs = 323; goto _test_eof; _test_eof324: cs = 324; goto _test_eof; _test_eof325: cs = 325; goto _test_eof; _test_eof326: cs = 326; goto _test_eof; _test_eof327: cs = 327; goto _test_eof; _test_eof328: cs = 328; goto _test_eof; _test_eof329: cs = 329; goto _test_eof; _test_eof330: cs = 330; goto _test_eof; _test_eof331: cs = 331; goto _test_eof; _test_eof332: cs = 332; goto _test_eof; _test_eof333: cs = 333; goto _test_eof; _test_eof334: cs = 334; goto _test_eof; _test_eof335: cs = 335; goto _test_eof; _test_eof336: cs = 336; goto _test_eof; _test_eof337: cs = 337; goto _test_eof; _test_eof338: cs = 338; goto _test_eof; _test_eof: {} if ( p == eof ) { switch ( cs ) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: case 200: case 201: case 202: case 203: case 204: case 205: case 206: case 207: case 208: case 209: case 210: case 211: case 212: case 213: case 214: case 215: case 216: case 217: case 218: case 219: case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: case 239: case 240: case 241: case 242: case 243: case 244: case 245: case 246: case 247: case 248: case 249: case 250: case 251: case 252: case 253: case 254: case 255: case 256: case 257: case 258: case 259: case 260: case 261: case 262: case 263: case 264: case 265: case 266: case 267: case 268: case 269: case 270: case 271: case 272: case 273: case 274: case 275: case 276: case 277: case 278: case 279: case 280: case 281: case 282: case 283: case 284: case 285: case 286: case 287: case 288: case 289: case 290: case 291: case 292: case 293: case 294: case 295: case 296: case 297: case 298: case 299: case 300: case 301: case 302: case 303: case 304: case 305: case 306: case 307: case 308: case 309: case 310: case 311: case 312: case 313: case 314: case 315: case 316: case 317: case 318: case 319: case 320: case 321: case 322: case 323: case 324: case 325: case 326: case 327: case 328: case 329: case 330: case 331: case 332: case 333: case 334: case 335: case 336: case 337: case 338: #line 7 "xmpp_uri.rl" { ret=0; } break; #line 6204 "xmpp_uri.c" } } _out: {} } #line 38 "xmpp_uri.rl" if (ret) return enif_make_atom(env, "true"); else return enif_make_atom(env, "false"); } static ErlNifFunc nif_funcs[] = { {"is_valid", 1, is_valid} }; ERL_NIF_INIT(xmpp_uri, nif_funcs, load, NULL, NULL, NULL) xmpp-1.4.4/c_src/uri.rl0000644000232200023220000000443313610066730015307 0ustar debalancedebalance# Generated by abnfc at Fri Jan 12 11:10:43 2018 # Output file: uri.rl # Sources: # core # uri.abnf %%{ # write your name machine uri; # generated rules, define required actions ALPHA = 0x41..0x5a | 0x61..0x7a; BIT = "0" | "1"; CHAR = 0x01..0x7f; CR = "\r"; LF = "\n"; CRLF = CR LF; CTL = 0x00..0x1f | 0x7f; DIGIT = 0x30..0x39; DQUOTE = "\""; HEXDIG = DIGIT | "A"i | "B"i | "C"i | "D"i | "E"i | "F"i; HTAB = "\t"; SP = " "; WSP = SP | HTAB; LWSP = ( WSP | ( CRLF WSP ) )*; OCTET = 0x00..0xff; VCHAR = 0x21..0x7e; unreserved = ALPHA | DIGIT | "-" | "." | "_" | "~"; pct_encoded = "%" HEXDIG HEXDIG; nodeallow = "!" | "$" | "(" | ")" | "*" | "+" | "," | ";" | "="; nodeid = ( unreserved | pct_encoded | nodeallow )*; h16 = HEXDIG{1,4}; dec_octet = DIGIT | ( 0x31..0x39 DIGIT ) | ( "1" DIGIT{2} ) | ( "2" 0x30..0x34 DIGIT ) | ( "25" 0x30..0x35 ); IPv4address = dec_octet "." dec_octet "." dec_octet "." dec_octet; ls32 = ( h16 ":" h16 ) | IPv4address; IPv6address = ( ( h16 ":" ){6} ls32 ) | ( "::" ( h16 ":" ){5} ls32 ) | ( h16? "::" ( h16 ":" ){4} ls32 ) | ( ( ( h16 ":" )? h16 )? "::" ( h16 ":" ){3} ls32 ) | ( ( ( h16 ":" ){,2} h16 )? "::" ( h16 ":" ){2} ls32 ) | ( ( ( h16 ":" ){,3} h16 )? "::" h16 ":" ls32 ) | ( ( ( h16 ":" ){,4} h16 )? "::" ls32 ) | ( ( ( h16 ":" ){,5} h16 )? "::" h16 ) | ( ( ( h16 ":" ){,6} h16 )? "::" ); sub_delims = "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ";" | "="; IPvFuture = "v"i HEXDIG+ "." ( unreserved | sub_delims | ":" )+; IP_literal = "[" ( IPv6address | IPvFuture ) "]"; reg_name = ( unreserved | pct_encoded | sub_delims )+; host = IP_literal | IPv4address | reg_name; authxmpp = nodeid "@" host; resallow = "!" | "$" | "&" | "'" | "(" | ")" | "*" | "+" | "," | ":" | ";" | "="; resid = ( unreserved | pct_encoded | resallow )*; pathxmpp = ( nodeid "@" )? host ( "/" resid )?; authpath = "//" authxmpp ( "/" pathxmpp )?; hierxmpp = authpath | pathxmpp; querytype = ( unreserved | pct_encoded )*; key = ( unreserved | pct_encoded )*; value = ( unreserved | pct_encoded )*; pair = ";" key "=" value; querycomp = querytype pair*?; pchar = unreserved | pct_encoded | sub_delims | ":" | "@"; fragment = ( pchar | "/" | "?" )*; xmppuri = "xmpp"i ":" hierxmpp ( "?" querycomp )? ( "#" fragment )?; query = ( pchar | "/" | "?" )*; }%% xmpp-1.4.4/c_src/utf8.rl0000644000232200023220000000165213610066730015376 0ustar debalancedebalance# Generated by abnfc at Fri Jan 12 11:10:43 2018 # Output file: utf8.rl # Sources: # core # utf8.abnf %%{ # write your name machine utf8; # generated rules, define required actions ALPHA = 0x41..0x5a | 0x61..0x7a; BIT = "0" | "1"; CHAR = 0x01..0x7f; CR = "\r"; LF = "\n"; CRLF = CR LF; CTL = 0x00..0x1f | 0x7f; DIGIT = 0x30..0x39; DQUOTE = "\""; HEXDIG = DIGIT | "A"i | "B"i | "C"i | "D"i | "E"i | "F"i; HTAB = "\t"; SP = " "; WSP = SP | HTAB; LWSP = ( WSP | ( CRLF WSP ) )*; OCTET = 0x00..0xff; VCHAR = 0x21..0x7e; UTF8_1 = 0x00..0x7f; UTF8_tail = 0x80..0xbf; UTF8_2 = 0xc2..0xdf UTF8_tail; UTF8_3 = ( 0xe0 0xa0..0xbf UTF8_tail ) | ( 0xe1..0xec UTF8_tail{2} ) | ( 0xed 0x80..0x9f UTF8_tail ) | ( 0xee..0xef UTF8_tail{2} ); UTF8_4 = ( 0xf0 0x90..0xbf UTF8_tail{2} ) | ( 0xf1..0xf3 UTF8_tail{3} ) | ( 0xf4 0x80..0x8f UTF8_tail{2} ); UTF8_char = UTF8_1 | UTF8_2 | UTF8_3 | UTF8_4; UTF8_octets = UTF8_char*; }%% xmpp-1.4.4/c_src/Makefile0000644000232200023220000000047713610066730015615 0ustar debalancedebalance# Download ABNF Compiler from https://github.com/zinid/abnfc ABNFC=abnfc all: $(ABNFC) core utf8.abnf -i -n utf8 -o utf8.rl $(ABNFC) core uri.abnf -i -n uri -o uri.rl $(ABNFC) core lang.abnf -i -n lang -o lang.rl ragel -G2 jid.rl -o jid.c ragel -G2 xmpp_uri.rl -o xmpp_uri.c ragel -G2 xmpp_lang.rl -o xmpp_lang.c xmpp-1.4.4/c_src/jid.rl0000644000232200023220000000466013610066730015260 0ustar debalancedebalance#include #include %%{ machine jid; include utf8 "utf8.rl"; action node_start { node_start = p; } action domain_start { domain_start = p; } action resource_start { resource_start = p; } action node_end { node_end = p; } action domain_end { domain_end = p; } action resource_end { resource_end = p; } action parse_error { ret = 0; } idbyte = UTF8_char -- (space | [\"&\'/:<>@]); domainbyte = UTF8_char -- (space | [.@/]); node = (idbyte+ '@')?; domain = (domainbyte+ '.')* domainbyte+ '.'?; resource = ('/' UTF8_char+)?; main := ( (node > node_start @ node_end) (domain > domain_start @ domain_end) (resource > resource_start @ resource_end) ) $! parse_error; }%% static const int jid_start = 1; static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { return 0; } static ERL_NIF_TERM mk_binary_term(ErlNifEnv* env, char *start, char *stop, int start_offset, int stop_offset) { ERL_NIF_TERM result; if (stop && start) { stop += stop_offset; start += start_offset; if (stop > start) { size_t size = stop - start; unsigned char *buf = enif_make_new_binary(env, size, &result); if (buf) { memcpy(buf, start, size); return result; } } } enif_make_new_binary(env, 0, &result); return result; } static ERL_NIF_TERM string_to_usr(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; ERL_NIF_TERM node, domain, resource; int cs = 0, ret = 1; char *node_start = NULL; char *node_end = NULL; char *domain_start = NULL; char *domain_end = NULL; char *resource_start = NULL; char *resource_end = NULL; if (argc != 1) return enif_make_badarg(env); if (!(enif_inspect_binary(env, argv[0], &input))) return enif_make_badarg(env); if (!input.size) return enif_make_atom(env, "error"); char *p = (char *) input.data; char *pe = p + input.size; char *eof = pe; %% write init; %% write exec; if (ret) { node = mk_binary_term(env, node_start, node_end, 0, 0); domain = mk_binary_term(env, domain_start, domain_end, 0, 1); resource = mk_binary_term(env, resource_start, resource_end, 1, 1); return enif_make_tuple3(env, node, domain, resource); } else { return enif_make_atom(env, "error"); } } static ErlNifFunc nif_funcs[] = { {"string_to_usr", 1, string_to_usr} }; ERL_NIF_INIT(jid, nif_funcs, load, NULL, NULL, NULL) xmpp-1.4.4/c_src/uri.abnf0000644000232200023220000000413113610066730015573 0ustar debalancedebalancexmppuri = "xmpp" ":" hierxmpp [ "?" querycomp ] [ "#" fragment ] hierxmpp = authpath / pathxmpp authpath = "//" authxmpp [ "/" pathxmpp ] authxmpp = nodeid "@" host pathxmpp = [ nodeid "@" ] host [ "/" resid ] nodeid = *( unreserved / pct-encoded / nodeallow ) nodeallow = "!" / "$" / "(" / ")" / "*" / "+" / "," / ";" / "=" resid = *( unreserved / pct-encoded / resallow ) resallow = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ":" / ";" / "=" querycomp = querytype [ *pair ] querytype = *( unreserved / pct-encoded ) pair = ";" key "=" value key = *( unreserved / pct-encoded ) value = *( unreserved / pct-encoded ) host = IP-literal / IPv4address / reg-name IP-literal = "[" ( IPv6address / IPvFuture ) "]" IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" ) IPv6address = 6( h16 ":" ) ls32 / "::" 5( h16 ":" ) ls32 / [ h16 ] "::" 4( h16 ":" ) ls32 / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 / [ *4( h16 ":" ) h16 ] "::" ls32 / [ *5( h16 ":" ) h16 ] "::" h16 / [ *6( h16 ":" ) h16 ] "::" h16 = 1*4HEXDIG ls32 = ( h16 ":" h16 ) / IPv4address IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet dec-octet = DIGIT ; 0-9 / %x31-39 DIGIT ; 10-99 / "1" 2DIGIT ; 100-199 / "2" %x30-34 DIGIT ; 200-249 / "25" %x30-35 ; 250-255 reg-name = 1*( unreserved / pct-encoded / sub-delims ) pchar = unreserved / pct-encoded / sub-delims / ":" / "@" query = *( pchar / "/" / "?" ) fragment = *( pchar / "/" / "?" ) pct-encoded = "%" HEXDIG HEXDIG unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" xmpp-1.4.4/c_src/lang.abnf0000644000232200023220000000610013610066730015713 0ustar debalancedebalancexmpplang = langtag ; normal language tags / privateuse ; private use tag / grandfathered ; grandfathered tags langtag = language ["-" script] ["-" region] *("-" variant) *("-" extension) ["-" privateuse] ["." encoding] language = 2*3ALPHA ; shortest ISO 639 code ["-" extlang] ; sometimes followed by ; extended language subtags / 4ALPHA ; or reserved for future use / 5*8ALPHA ; or registered language subtag extlang = 3ALPHA ; selected ISO 639 codes *2("-" 3ALPHA) ; permanently reserved script = 4ALPHA ; ISO 15924 code region = 2ALPHA ; ISO 3166-1 code / 3DIGIT ; UN M.49 code variant = 5*8alphanum ; registered variants / (DIGIT 3alphanum) extension = singleton 1*("-" (2*8alphanum)) ; Single alphanumerics ; "x" reserved for private use singleton = DIGIT ; 0 - 9 / %x41-57 ; A - W / %x59-5A ; Y - Z / %x61-77 ; a - w / %x79-7A ; y - z privateuse = "x" 1*("-" (1*8alphanum)) encoding = "UTF-8" ; work-around for Cisco Jabber grandfathered = irregular ; non-redundant tags registered / regular ; during the RFC 3066 era irregular = "en-GB-oed" ; irregular tags do not match / "i-ami" ; the 'langtag' production and / "i-bnn" ; would not otherwise be / "i-default" ; considered 'well-formed' / "i-enochian" ; These tags are all valid, / "i-hak" ; but most are deprecated / "i-klingon" ; in favor of more modern / "i-lux" ; subtags or subtag / "i-mingo" ; combination / "i-navajo" / "i-pwn" / "i-tao" / "i-tay" / "i-tsu" / "sgn-BE-FR" / "sgn-BE-NL" / "sgn-CH-DE" regular = "art-lojban" ; these tags match the 'langtag' / "cel-gaulish" ; production, but their subtags / "no-bok" ; are not extended language / "no-nyn" ; or variant subtags: their meaning / "zh-guoyu" ; is defined by their registration / "zh-hakka" ; and all of these are deprecated / "zh-min" ; in favor of a more modern / "zh-min-nan" ; subtag or sequence of subtags / "zh-xiang" alphanum = (ALPHA / DIGIT) ; letters and numbers xmpp-1.4.4/c_src/xmpp_lang.rl0000644000232200023220000000173213610066730016474 0ustar debalancedebalance#include #include %%{ machine xmpp_lang; include lang "lang.rl"; action lang_parse_error { ret=0; } main := xmpplang $! lang_parse_error; }%% static const int xmpp_lang_start = 1; static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { return 0; } static ERL_NIF_TERM is_valid(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; int cs = 0, ret = 1; if (argc != 1) return enif_make_badarg(env); if (!(enif_inspect_binary(env, argv[0], &input))) return enif_make_badarg(env); if (!input.size) return enif_make_atom(env, "false"); char *p = (char *) input.data; char *pe = p + input.size; char *eof = pe; %% write init; %% write exec; if (ret) return enif_make_atom(env, "true"); else return enif_make_atom(env, "false"); } static ErlNifFunc nif_funcs[] = { {"is_valid", 1, is_valid} }; ERL_NIF_INIT(xmpp_lang, nif_funcs, load, NULL, NULL, NULL) xmpp-1.4.4/c_src/xmpp_uri.rl0000644000232200023220000000172213610066730016351 0ustar debalancedebalance#include #include %%{ machine xmpp_uri; include uri "uri.rl"; action uri_parse_error { ret=0; } main := xmppuri $! uri_parse_error; }%% static const int xmpp_uri_start = 1; static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { return 0; } static ERL_NIF_TERM is_valid(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; int cs = 0, ret = 1; if (argc != 1) return enif_make_badarg(env); if (!(enif_inspect_binary(env, argv[0], &input))) return enif_make_badarg(env); if (!input.size) return enif_make_atom(env, "false"); char *p = (char *) input.data; char *pe = p + input.size; char *eof = pe; %% write init; %% write exec; if (ret) return enif_make_atom(env, "true"); else return enif_make_atom(env, "false"); } static ErlNifFunc nif_funcs[] = { {"is_valid", 1, is_valid} }; ERL_NIF_INIT(xmpp_uri, nif_funcs, load, NULL, NULL, NULL) xmpp-1.4.4/c_src/lang.rl0000644000232200023220000000302213610066730015422 0ustar debalancedebalance# Generated by abnfc at Mon Dec 10 17:57:16 2018 # Output file: lang.rl # Sources: # core # lang.abnf %%{ # write your name machine lang; # generated rules, define required actions ALPHA = 0x41..0x5a | 0x61..0x7a; BIT = "0" | "1"; CHAR = 0x01..0x7f; CR = "\r"; LF = "\n"; CRLF = CR LF; CTL = 0x00..0x1f | 0x7f; DIGIT = 0x30..0x39; DQUOTE = "\""; HEXDIG = DIGIT | "A"i | "B"i | "C"i | "D"i | "E"i | "F"i; HTAB = "\t"; SP = " "; WSP = SP | HTAB; LWSP = ( WSP | ( CRLF WSP ) )*; OCTET = 0x00..0xff; VCHAR = 0x21..0x7e; extlang = ALPHA{3} ( "-" ALPHA{3} ){,2}; language = ( ALPHA{2,3} ( "-" extlang )? ) | ALPHA{4} | ALPHA{5,8}; script = ALPHA{4}; region = ALPHA{2} | DIGIT{3}; alphanum = ( ALPHA | DIGIT ); variant = alphanum{5,8} | ( DIGIT alphanum{3} ); singleton = DIGIT | 0x41..0x57 | 0x59..0x5a | 0x61..0x77 | 0x79..0x7a; extension = singleton ( "-" alphanum{2,8} )+; privateuse = "x"i ( "-" alphanum{1,8} )+; encoding = "UTF-8"i; langtag = language ( "-" script )? ( "-" region )? ( "-" variant )* ( "-" extension )* ( "-" privateuse )? ( "." encoding )?; irregular = "en-GB-oed"i | "i-ami"i | "i-bnn"i | "i-default"i | "i-enochian"i | "i-hak"i | "i-klingon"i | "i-lux"i | "i-mingo"i | "i-navajo"i | "i-pwn"i | "i-tao"i | "i-tay"i | "i-tsu"i | "sgn-BE-FR"i | "sgn-BE-NL"i | "sgn-CH-DE"i; regular = "art-lojban"i | "cel-gaulish"i | "no-bok"i | "no-nyn"i | "zh-guoyu"i | "zh-hakka"i | "zh-min"i | "zh-min-nan"i | "zh-xiang"i; grandfathered = irregular | regular; xmpplang = langtag | privateuse | grandfathered; }%% xmpp-1.4.4/c_src/utf8.abnf0000644000232200023220000000060613610066730015665 0ustar debalancedebalanceUTF8-octets = *( UTF8-char ) UTF8-char = UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4 UTF8-1 = %x00-7F UTF8-2 = %xC2-DF UTF8-tail UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) / %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail ) UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) / %xF4 %x80-8F 2( UTF8-tail ) UTF8-tail = %x80-BF xmpp-1.4.4/c_src/xmpp_lang.c0000644000232200023220000012416513610066730016307 0ustar debalancedebalance #line 1 "xmpp_lang.rl" #include #include #line 9 "xmpp_lang.rl" static const int xmpp_lang_start = 1; static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { return 0; } static ERL_NIF_TERM is_valid(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; int cs = 0, ret = 1; if (argc != 1) return enif_make_badarg(env); if (!(enif_inspect_binary(env, argv[0], &input))) return enif_make_badarg(env); if (!input.size) return enif_make_atom(env, "false"); char *p = (char *) input.data; char *pe = p + input.size; char *eof = pe; #line 37 "xmpp_lang.c" { cs = xmpp_lang_start; } #line 37 "xmpp_lang.rl" #line 44 "xmpp_lang.c" { if ( p == pe ) goto _test_eof; switch ( cs ) { case 1: switch( (*p) ) { case 69: goto st41; case 73: goto st47; case 83: goto st86; case 88: goto st95; case 101: goto st41; case 105: goto st47; case 115: goto st86; case 120: goto st95; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st2; } else if ( (*p) >= 65 ) goto st2; goto tr0; tr0: #line 7 "xmpp_lang.rl" { ret=0; } goto st0; #line 71 "xmpp_lang.c" st0: cs = 0; goto _out; st2: if ( ++p == pe ) goto _test_eof2; case 2: if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st97; } else if ( (*p) >= 65 ) goto st97; goto tr0; st97: if ( ++p == pe ) goto _test_eof97; case 97: switch( (*p) ) { case 45: goto st3; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st129; } else if ( (*p) >= 65 ) goto st129; goto tr0; st3: if ( ++p == pe ) goto _test_eof3; case 3: switch( (*p) ) { case 88: goto st40; case 120: goto st40; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st4; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st26; } else goto st26; goto tr0; st4: if ( ++p == pe ) goto _test_eof4; case 4: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st16; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st19; } else goto st19; goto tr0; st5: if ( ++p == pe ) goto _test_eof5; case 5: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st6; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st6; } else goto st6; goto tr0; st6: if ( ++p == pe ) goto _test_eof6; case 6: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st98; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st98; } else goto st98; goto tr0; st98: if ( ++p == pe ) goto _test_eof98; case 98: switch( (*p) ) { case 45: goto st7; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st108; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st108; } else goto st108; goto tr0; st7: if ( ++p == pe ) goto _test_eof7; case 7: switch( (*p) ) { case 88: goto st9; case 120: goto st9; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st8; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st8; } else goto st8; goto tr0; st8: if ( ++p == pe ) goto _test_eof8; case 8: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st98; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st98; } else goto st98; goto tr0; st9: if ( ++p == pe ) goto _test_eof9; case 9: if ( (*p) == 45 ) goto st10; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st98; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st98; } else goto st98; goto tr0; st10: if ( ++p == pe ) goto _test_eof10; case 10: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st99; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st99; } else goto st99; goto tr0; st99: if ( ++p == pe ) goto _test_eof99; case 99: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st101; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st101; } else goto st101; goto tr0; st11: if ( ++p == pe ) goto _test_eof11; case 11: switch( (*p) ) { case 85: goto st12; case 117: goto st12; } goto tr0; st12: if ( ++p == pe ) goto _test_eof12; case 12: switch( (*p) ) { case 84: goto st13; case 116: goto st13; } goto tr0; st13: if ( ++p == pe ) goto _test_eof13; case 13: switch( (*p) ) { case 70: goto st14; case 102: goto st14; } goto tr0; st14: if ( ++p == pe ) goto _test_eof14; case 14: if ( (*p) == 45 ) goto st15; goto tr0; st15: if ( ++p == pe ) goto _test_eof15; case 15: if ( (*p) == 56 ) goto st100; goto tr0; st100: if ( ++p == pe ) goto _test_eof100; case 100: goto tr0; st101: if ( ++p == pe ) goto _test_eof101; case 101: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st102; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st102; } else goto st102; goto tr0; st102: if ( ++p == pe ) goto _test_eof102; case 102: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st103; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st103; } else goto st103; goto tr0; st103: if ( ++p == pe ) goto _test_eof103; case 103: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st104; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st104; } else goto st104; goto tr0; st104: if ( ++p == pe ) goto _test_eof104; case 104: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st105; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st105; } else goto st105; goto tr0; st105: if ( ++p == pe ) goto _test_eof105; case 105: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st106; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st106; } else goto st106; goto tr0; st106: if ( ++p == pe ) goto _test_eof106; case 106: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st107; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st107; } else goto st107; goto tr0; st107: if ( ++p == pe ) goto _test_eof107; case 107: switch( (*p) ) { case 45: goto st10; case 46: goto st11; } goto tr0; st108: if ( ++p == pe ) goto _test_eof108; case 108: switch( (*p) ) { case 45: goto st7; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st109; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st109; } else goto st109; goto tr0; st109: if ( ++p == pe ) goto _test_eof109; case 109: switch( (*p) ) { case 45: goto st7; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st110; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st110; } else goto st110; goto tr0; st110: if ( ++p == pe ) goto _test_eof110; case 110: switch( (*p) ) { case 45: goto st7; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st111; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st111; } else goto st111; goto tr0; st111: if ( ++p == pe ) goto _test_eof111; case 111: switch( (*p) ) { case 45: goto st7; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st112; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st112; } else goto st112; goto tr0; st112: if ( ++p == pe ) goto _test_eof112; case 112: switch( (*p) ) { case 45: goto st7; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st113; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st113; } else goto st113; goto tr0; st113: if ( ++p == pe ) goto _test_eof113; case 113: switch( (*p) ) { case 45: goto st7; case 46: goto st11; } goto tr0; st16: if ( ++p == pe ) goto _test_eof16; case 16: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st114; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st20; } else goto st20; goto tr0; st114: if ( ++p == pe ) goto _test_eof114; case 114: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st115; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st115; } else goto st115; goto tr0; st17: if ( ++p == pe ) goto _test_eof17; case 17: switch( (*p) ) { case 88: goto st25; case 120: goto st25; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st18; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st21; } else goto st21; goto tr0; st18: if ( ++p == pe ) goto _test_eof18; case 18: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st19; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st19; } else goto st19; goto tr0; st19: if ( ++p == pe ) goto _test_eof19; case 19: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st20; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st20; } else goto st20; goto tr0; st20: if ( ++p == pe ) goto _test_eof20; case 20: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st115; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st115; } else goto st115; goto tr0; st115: if ( ++p == pe ) goto _test_eof115; case 115: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st116; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st116; } else goto st116; goto tr0; st116: if ( ++p == pe ) goto _test_eof116; case 116: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st117; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st117; } else goto st117; goto tr0; st117: if ( ++p == pe ) goto _test_eof117; case 117: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st118; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st118; } else goto st118; goto tr0; st118: if ( ++p == pe ) goto _test_eof118; case 118: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st119; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st119; } else goto st119; goto tr0; st119: if ( ++p == pe ) goto _test_eof119; case 119: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } goto tr0; st21: if ( ++p == pe ) goto _test_eof21; case 21: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st22; } else goto st22; goto tr0; st22: if ( ++p == pe ) goto _test_eof22; case 22: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st23; } else goto st23; goto tr0; st23: if ( ++p == pe ) goto _test_eof23; case 23: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st24; } else goto st24; goto tr0; st24: if ( ++p == pe ) goto _test_eof24; case 24: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st116; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st116; } else goto st116; goto tr0; st25: if ( ++p == pe ) goto _test_eof25; case 25: if ( (*p) == 45 ) goto st10; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st22; } else goto st22; goto tr0; st26: if ( ++p == pe ) goto _test_eof26; case 26: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st120; } else goto st120; goto tr0; st120: if ( ++p == pe ) goto _test_eof120; case 120: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st121; } else goto st121; goto tr0; st121: if ( ++p == pe ) goto _test_eof121; case 121: switch( (*p) ) { case 45: goto st27; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st127; } else goto st127; goto tr0; st27: if ( ++p == pe ) goto _test_eof27; case 27: switch( (*p) ) { case 88: goto st39; case 120: goto st39; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st4; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st28; } else goto st28; goto tr0; st28: if ( ++p == pe ) goto _test_eof28; case 28: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st122; } else goto st122; goto tr0; st122: if ( ++p == pe ) goto _test_eof122; case 122: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st123; } else goto st123; goto tr0; st123: if ( ++p == pe ) goto _test_eof123; case 123: switch( (*p) ) { case 45: goto st29; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st127; } else goto st127; goto tr0; st29: if ( ++p == pe ) goto _test_eof29; case 29: switch( (*p) ) { case 88: goto st38; case 120: goto st38; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st4; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st30; } else goto st30; goto tr0; st30: if ( ++p == pe ) goto _test_eof30; case 30: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st124; } else goto st124; goto tr0; st124: if ( ++p == pe ) goto _test_eof124; case 124: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st125; } else goto st125; goto tr0; st125: if ( ++p == pe ) goto _test_eof125; case 125: switch( (*p) ) { case 45: goto st31; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st127; } else goto st127; goto tr0; st31: if ( ++p == pe ) goto _test_eof31; case 31: switch( (*p) ) { case 88: goto st37; case 120: goto st37; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st4; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st32; } else goto st32; goto tr0; st32: if ( ++p == pe ) goto _test_eof32; case 32: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st126; } else goto st126; goto tr0; st126: if ( ++p == pe ) goto _test_eof126; case 126: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st33; } else goto st33; goto tr0; st33: if ( ++p == pe ) goto _test_eof33; case 33: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st127; } else goto st127; goto tr0; st127: if ( ++p == pe ) goto _test_eof127; case 127: switch( (*p) ) { case 45: goto st34; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st116; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st116; } else goto st116; goto tr0; st34: if ( ++p == pe ) goto _test_eof34; case 34: switch( (*p) ) { case 88: goto st36; case 120: goto st36; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st4; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st35; } else goto st35; goto tr0; st35: if ( ++p == pe ) goto _test_eof35; case 35: if ( (*p) == 45 ) goto st5; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st128; } else goto st128; goto tr0; st128: if ( ++p == pe ) goto _test_eof128; case 128: switch( (*p) ) { case 45: goto st17; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st23; } else goto st23; goto tr0; st36: if ( ++p == pe ) goto _test_eof36; case 36: if ( (*p) == 45 ) goto st10; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st128; } else goto st128; goto tr0; st37: if ( ++p == pe ) goto _test_eof37; case 37: if ( (*p) == 45 ) goto st10; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st126; } else goto st126; goto tr0; st38: if ( ++p == pe ) goto _test_eof38; case 38: if ( (*p) == 45 ) goto st10; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st124; } else goto st124; goto tr0; st39: if ( ++p == pe ) goto _test_eof39; case 39: if ( (*p) == 45 ) goto st10; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st122; } else goto st122; goto tr0; st40: if ( ++p == pe ) goto _test_eof40; case 40: if ( (*p) == 45 ) goto st10; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st120; } else goto st120; goto tr0; st129: if ( ++p == pe ) goto _test_eof129; case 129: switch( (*p) ) { case 45: goto st3; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st130; } else if ( (*p) >= 65 ) goto st130; goto tr0; st130: if ( ++p == pe ) goto _test_eof130; case 130: switch( (*p) ) { case 45: goto st31; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st131; } else if ( (*p) >= 65 ) goto st131; goto tr0; st131: if ( ++p == pe ) goto _test_eof131; case 131: switch( (*p) ) { case 45: goto st31; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st132; } else if ( (*p) >= 65 ) goto st132; goto tr0; st132: if ( ++p == pe ) goto _test_eof132; case 132: switch( (*p) ) { case 45: goto st31; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st133; } else if ( (*p) >= 65 ) goto st133; goto tr0; st133: if ( ++p == pe ) goto _test_eof133; case 133: switch( (*p) ) { case 45: goto st31; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st134; } else if ( (*p) >= 65 ) goto st134; goto tr0; st134: if ( ++p == pe ) goto _test_eof134; case 134: switch( (*p) ) { case 45: goto st31; case 46: goto st11; } goto tr0; st41: if ( ++p == pe ) goto _test_eof41; case 41: switch( (*p) ) { case 78: goto st135; case 110: goto st135; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st97; } else if ( (*p) >= 65 ) goto st97; goto tr0; st135: if ( ++p == pe ) goto _test_eof135; case 135: switch( (*p) ) { case 45: goto st42; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st129; } else if ( (*p) >= 65 ) goto st129; goto tr0; st42: if ( ++p == pe ) goto _test_eof42; case 42: switch( (*p) ) { case 71: goto st43; case 88: goto st40; case 103: goto st43; case 120: goto st40; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st4; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st26; } else goto st26; goto tr0; st43: if ( ++p == pe ) goto _test_eof43; case 43: switch( (*p) ) { case 45: goto st5; case 66: goto st136; case 98: goto st136; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st120; } else goto st120; goto tr0; st136: if ( ++p == pe ) goto _test_eof136; case 136: switch( (*p) ) { case 45: goto st44; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st121; } else goto st121; goto tr0; st44: if ( ++p == pe ) goto _test_eof44; case 44: switch( (*p) ) { case 79: goto st45; case 88: goto st25; case 111: goto st45; case 120: goto st25; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st18; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st21; } else goto st21; goto tr0; st45: if ( ++p == pe ) goto _test_eof45; case 45: switch( (*p) ) { case 45: goto st5; case 69: goto st46; case 101: goto st46; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st22; } else goto st22; goto tr0; st46: if ( ++p == pe ) goto _test_eof46; case 46: switch( (*p) ) { case 68: goto st137; case 100: goto st137; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st23; } else goto st23; goto tr0; st137: if ( ++p == pe ) goto _test_eof137; case 137: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st24; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st24; } else goto st24; goto tr0; st47: if ( ++p == pe ) goto _test_eof47; case 47: if ( (*p) == 45 ) goto st48; if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st97; } else if ( (*p) >= 65 ) goto st97; goto tr0; st48: if ( ++p == pe ) goto _test_eof48; case 48: switch( (*p) ) { case 65: goto st49; case 66: goto st51; case 68: goto st53; case 69: goto st59; case 72: goto st65; case 75: goto st67; case 76: goto st72; case 77: goto st74; case 78: goto st78; case 80: goto st82; case 84: goto st83; case 97: goto st49; case 98: goto st51; case 100: goto st53; case 101: goto st59; case 104: goto st65; case 107: goto st67; case 108: goto st72; case 109: goto st74; case 110: goto st78; case 112: goto st82; case 116: goto st83; } goto tr0; st49: if ( ++p == pe ) goto _test_eof49; case 49: switch( (*p) ) { case 77: goto st50; case 109: goto st50; } goto tr0; st50: if ( ++p == pe ) goto _test_eof50; case 50: switch( (*p) ) { case 73: goto st100; case 105: goto st100; } goto tr0; st51: if ( ++p == pe ) goto _test_eof51; case 51: switch( (*p) ) { case 78: goto st52; case 110: goto st52; } goto tr0; st52: if ( ++p == pe ) goto _test_eof52; case 52: switch( (*p) ) { case 78: goto st100; case 110: goto st100; } goto tr0; st53: if ( ++p == pe ) goto _test_eof53; case 53: switch( (*p) ) { case 69: goto st54; case 101: goto st54; } goto tr0; st54: if ( ++p == pe ) goto _test_eof54; case 54: switch( (*p) ) { case 70: goto st55; case 102: goto st55; } goto tr0; st55: if ( ++p == pe ) goto _test_eof55; case 55: switch( (*p) ) { case 65: goto st56; case 97: goto st56; } goto tr0; st56: if ( ++p == pe ) goto _test_eof56; case 56: switch( (*p) ) { case 85: goto st57; case 117: goto st57; } goto tr0; st57: if ( ++p == pe ) goto _test_eof57; case 57: switch( (*p) ) { case 76: goto st58; case 108: goto st58; } goto tr0; st58: if ( ++p == pe ) goto _test_eof58; case 58: switch( (*p) ) { case 84: goto st100; case 116: goto st100; } goto tr0; st59: if ( ++p == pe ) goto _test_eof59; case 59: switch( (*p) ) { case 78: goto st60; case 110: goto st60; } goto tr0; st60: if ( ++p == pe ) goto _test_eof60; case 60: switch( (*p) ) { case 79: goto st61; case 111: goto st61; } goto tr0; st61: if ( ++p == pe ) goto _test_eof61; case 61: switch( (*p) ) { case 67: goto st62; case 99: goto st62; } goto tr0; st62: if ( ++p == pe ) goto _test_eof62; case 62: switch( (*p) ) { case 72: goto st63; case 104: goto st63; } goto tr0; st63: if ( ++p == pe ) goto _test_eof63; case 63: switch( (*p) ) { case 73: goto st64; case 105: goto st64; } goto tr0; st64: if ( ++p == pe ) goto _test_eof64; case 64: switch( (*p) ) { case 65: goto st52; case 97: goto st52; } goto tr0; st65: if ( ++p == pe ) goto _test_eof65; case 65: switch( (*p) ) { case 65: goto st66; case 97: goto st66; } goto tr0; st66: if ( ++p == pe ) goto _test_eof66; case 66: switch( (*p) ) { case 75: goto st100; case 107: goto st100; } goto tr0; st67: if ( ++p == pe ) goto _test_eof67; case 67: switch( (*p) ) { case 76: goto st68; case 108: goto st68; } goto tr0; st68: if ( ++p == pe ) goto _test_eof68; case 68: switch( (*p) ) { case 73: goto st69; case 105: goto st69; } goto tr0; st69: if ( ++p == pe ) goto _test_eof69; case 69: switch( (*p) ) { case 78: goto st70; case 110: goto st70; } goto tr0; st70: if ( ++p == pe ) goto _test_eof70; case 70: switch( (*p) ) { case 71: goto st71; case 103: goto st71; } goto tr0; st71: if ( ++p == pe ) goto _test_eof71; case 71: switch( (*p) ) { case 79: goto st52; case 111: goto st52; } goto tr0; st72: if ( ++p == pe ) goto _test_eof72; case 72: switch( (*p) ) { case 85: goto st73; case 117: goto st73; } goto tr0; st73: if ( ++p == pe ) goto _test_eof73; case 73: switch( (*p) ) { case 88: goto st100; case 120: goto st100; } goto tr0; st74: if ( ++p == pe ) goto _test_eof74; case 74: switch( (*p) ) { case 73: goto st75; case 105: goto st75; } goto tr0; st75: if ( ++p == pe ) goto _test_eof75; case 75: switch( (*p) ) { case 78: goto st76; case 110: goto st76; } goto tr0; st76: if ( ++p == pe ) goto _test_eof76; case 76: switch( (*p) ) { case 71: goto st77; case 103: goto st77; } goto tr0; st77: if ( ++p == pe ) goto _test_eof77; case 77: switch( (*p) ) { case 79: goto st100; case 111: goto st100; } goto tr0; st78: if ( ++p == pe ) goto _test_eof78; case 78: switch( (*p) ) { case 65: goto st79; case 97: goto st79; } goto tr0; st79: if ( ++p == pe ) goto _test_eof79; case 79: switch( (*p) ) { case 86: goto st80; case 118: goto st80; } goto tr0; st80: if ( ++p == pe ) goto _test_eof80; case 80: switch( (*p) ) { case 65: goto st81; case 97: goto st81; } goto tr0; st81: if ( ++p == pe ) goto _test_eof81; case 81: switch( (*p) ) { case 74: goto st77; case 106: goto st77; } goto tr0; st82: if ( ++p == pe ) goto _test_eof82; case 82: switch( (*p) ) { case 87: goto st52; case 119: goto st52; } goto tr0; st83: if ( ++p == pe ) goto _test_eof83; case 83: switch( (*p) ) { case 65: goto st84; case 83: goto st85; case 97: goto st84; case 115: goto st85; } goto tr0; st84: if ( ++p == pe ) goto _test_eof84; case 84: switch( (*p) ) { case 79: goto st100; case 89: goto st100; case 111: goto st100; case 121: goto st100; } goto tr0; st85: if ( ++p == pe ) goto _test_eof85; case 85: switch( (*p) ) { case 85: goto st100; case 117: goto st100; } goto tr0; st86: if ( ++p == pe ) goto _test_eof86; case 86: switch( (*p) ) { case 71: goto st138; case 103: goto st138; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st97; } else if ( (*p) >= 65 ) goto st97; goto tr0; st138: if ( ++p == pe ) goto _test_eof138; case 138: switch( (*p) ) { case 45: goto st3; case 46: goto st11; case 78: goto st139; case 110: goto st139; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st129; } else if ( (*p) >= 65 ) goto st129; goto tr0; st139: if ( ++p == pe ) goto _test_eof139; case 139: switch( (*p) ) { case 45: goto st87; case 46: goto st11; } if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st130; } else if ( (*p) >= 65 ) goto st130; goto tr0; st87: if ( ++p == pe ) goto _test_eof87; case 87: switch( (*p) ) { case 66: goto st88; case 67: goto st92; case 88: goto st40; case 98: goto st88; case 99: goto st92; case 120: goto st40; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st4; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st26; } else goto st26; goto tr0; st88: if ( ++p == pe ) goto _test_eof88; case 88: switch( (*p) ) { case 45: goto st5; case 69: goto st140; case 101: goto st140; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st120; } else goto st120; goto tr0; st140: if ( ++p == pe ) goto _test_eof140; case 140: switch( (*p) ) { case 45: goto st89; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st121; } else goto st121; goto tr0; st89: if ( ++p == pe ) goto _test_eof89; case 89: switch( (*p) ) { case 70: goto st90; case 78: goto st91; case 88: goto st25; case 102: goto st90; case 110: goto st91; case 120: goto st25; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st18; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st21; } else goto st21; goto tr0; st90: if ( ++p == pe ) goto _test_eof90; case 90: switch( (*p) ) { case 45: goto st5; case 82: goto st141; case 114: goto st141; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st22; } else goto st22; goto tr0; st141: if ( ++p == pe ) goto _test_eof141; case 141: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st23; } else goto st23; goto tr0; st91: if ( ++p == pe ) goto _test_eof91; case 91: switch( (*p) ) { case 45: goto st5; case 76: goto st141; case 108: goto st141; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st22; } else goto st22; goto tr0; st92: if ( ++p == pe ) goto _test_eof92; case 92: switch( (*p) ) { case 45: goto st5; case 72: goto st142; case 104: goto st142; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st120; } else goto st120; goto tr0; st142: if ( ++p == pe ) goto _test_eof142; case 142: switch( (*p) ) { case 45: goto st93; case 46: goto st11; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st23; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st121; } else goto st121; goto tr0; st93: if ( ++p == pe ) goto _test_eof93; case 93: switch( (*p) ) { case 68: goto st94; case 88: goto st25; case 100: goto st94; case 120: goto st25; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st18; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st21; } else goto st21; goto tr0; st94: if ( ++p == pe ) goto _test_eof94; case 94: switch( (*p) ) { case 45: goto st5; case 69: goto st141; case 101: goto st141; } if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st22; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st22; } else goto st22; goto tr0; st95: if ( ++p == pe ) goto _test_eof95; case 95: if ( (*p) == 45 ) goto st96; if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st97; } else if ( (*p) >= 65 ) goto st97; goto tr0; st96: if ( ++p == pe ) goto _test_eof96; case 96: if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st143; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st143; } else goto st143; goto tr0; st143: if ( ++p == pe ) goto _test_eof143; case 143: if ( (*p) == 45 ) goto st96; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st144; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st144; } else goto st144; goto tr0; st144: if ( ++p == pe ) goto _test_eof144; case 144: if ( (*p) == 45 ) goto st96; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st145; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st145; } else goto st145; goto tr0; st145: if ( ++p == pe ) goto _test_eof145; case 145: if ( (*p) == 45 ) goto st96; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st146; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st146; } else goto st146; goto tr0; st146: if ( ++p == pe ) goto _test_eof146; case 146: if ( (*p) == 45 ) goto st96; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st147; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st147; } else goto st147; goto tr0; st147: if ( ++p == pe ) goto _test_eof147; case 147: if ( (*p) == 45 ) goto st96; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st148; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st148; } else goto st148; goto tr0; st148: if ( ++p == pe ) goto _test_eof148; case 148: if ( (*p) == 45 ) goto st96; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st149; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st149; } else goto st149; goto tr0; st149: if ( ++p == pe ) goto _test_eof149; case 149: if ( (*p) == 45 ) goto st96; if ( (*p) < 65 ) { if ( 48 <= (*p) && (*p) <= 57 ) goto st150; } else if ( (*p) > 90 ) { if ( 97 <= (*p) && (*p) <= 122 ) goto st150; } else goto st150; goto tr0; st150: if ( ++p == pe ) goto _test_eof150; case 150: if ( (*p) == 45 ) goto st96; goto tr0; } _test_eof2: cs = 2; goto _test_eof; _test_eof97: cs = 97; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof98: cs = 98; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; _test_eof10: cs = 10; goto _test_eof; _test_eof99: cs = 99; goto _test_eof; _test_eof11: cs = 11; goto _test_eof; _test_eof12: cs = 12; goto _test_eof; _test_eof13: cs = 13; goto _test_eof; _test_eof14: cs = 14; goto _test_eof; _test_eof15: cs = 15; goto _test_eof; _test_eof100: cs = 100; goto _test_eof; _test_eof101: cs = 101; goto _test_eof; _test_eof102: cs = 102; goto _test_eof; _test_eof103: cs = 103; goto _test_eof; _test_eof104: cs = 104; goto _test_eof; _test_eof105: cs = 105; goto _test_eof; _test_eof106: cs = 106; goto _test_eof; _test_eof107: cs = 107; goto _test_eof; _test_eof108: cs = 108; goto _test_eof; _test_eof109: cs = 109; goto _test_eof; _test_eof110: cs = 110; goto _test_eof; _test_eof111: cs = 111; goto _test_eof; _test_eof112: cs = 112; goto _test_eof; _test_eof113: cs = 113; goto _test_eof; _test_eof16: cs = 16; goto _test_eof; _test_eof114: cs = 114; goto _test_eof; _test_eof17: cs = 17; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; _test_eof20: cs = 20; goto _test_eof; _test_eof115: cs = 115; goto _test_eof; _test_eof116: cs = 116; goto _test_eof; _test_eof117: cs = 117; goto _test_eof; _test_eof118: cs = 118; goto _test_eof; _test_eof119: cs = 119; goto _test_eof; _test_eof21: cs = 21; goto _test_eof; _test_eof22: cs = 22; goto _test_eof; _test_eof23: cs = 23; goto _test_eof; _test_eof24: cs = 24; goto _test_eof; _test_eof25: cs = 25; goto _test_eof; _test_eof26: cs = 26; goto _test_eof; _test_eof120: cs = 120; goto _test_eof; _test_eof121: cs = 121; goto _test_eof; _test_eof27: cs = 27; goto _test_eof; _test_eof28: cs = 28; goto _test_eof; _test_eof122: cs = 122; goto _test_eof; _test_eof123: cs = 123; goto _test_eof; _test_eof29: cs = 29; goto _test_eof; _test_eof30: cs = 30; goto _test_eof; _test_eof124: cs = 124; goto _test_eof; _test_eof125: cs = 125; goto _test_eof; _test_eof31: cs = 31; goto _test_eof; _test_eof32: cs = 32; goto _test_eof; _test_eof126: cs = 126; goto _test_eof; _test_eof33: cs = 33; goto _test_eof; _test_eof127: cs = 127; goto _test_eof; _test_eof34: cs = 34; goto _test_eof; _test_eof35: cs = 35; goto _test_eof; _test_eof128: cs = 128; goto _test_eof; _test_eof36: cs = 36; goto _test_eof; _test_eof37: cs = 37; goto _test_eof; _test_eof38: cs = 38; goto _test_eof; _test_eof39: cs = 39; goto _test_eof; _test_eof40: cs = 40; goto _test_eof; _test_eof129: cs = 129; goto _test_eof; _test_eof130: cs = 130; goto _test_eof; _test_eof131: cs = 131; goto _test_eof; _test_eof132: cs = 132; goto _test_eof; _test_eof133: cs = 133; goto _test_eof; _test_eof134: cs = 134; goto _test_eof; _test_eof41: cs = 41; goto _test_eof; _test_eof135: cs = 135; goto _test_eof; _test_eof42: cs = 42; goto _test_eof; _test_eof43: cs = 43; goto _test_eof; _test_eof136: cs = 136; goto _test_eof; _test_eof44: cs = 44; goto _test_eof; _test_eof45: cs = 45; goto _test_eof; _test_eof46: cs = 46; goto _test_eof; _test_eof137: cs = 137; goto _test_eof; _test_eof47: cs = 47; goto _test_eof; _test_eof48: cs = 48; goto _test_eof; _test_eof49: cs = 49; goto _test_eof; _test_eof50: cs = 50; goto _test_eof; _test_eof51: cs = 51; goto _test_eof; _test_eof52: cs = 52; goto _test_eof; _test_eof53: cs = 53; goto _test_eof; _test_eof54: cs = 54; goto _test_eof; _test_eof55: cs = 55; goto _test_eof; _test_eof56: cs = 56; goto _test_eof; _test_eof57: cs = 57; goto _test_eof; _test_eof58: cs = 58; goto _test_eof; _test_eof59: cs = 59; goto _test_eof; _test_eof60: cs = 60; goto _test_eof; _test_eof61: cs = 61; goto _test_eof; _test_eof62: cs = 62; goto _test_eof; _test_eof63: cs = 63; goto _test_eof; _test_eof64: cs = 64; goto _test_eof; _test_eof65: cs = 65; goto _test_eof; _test_eof66: cs = 66; goto _test_eof; _test_eof67: cs = 67; goto _test_eof; _test_eof68: cs = 68; goto _test_eof; _test_eof69: cs = 69; goto _test_eof; _test_eof70: cs = 70; goto _test_eof; _test_eof71: cs = 71; goto _test_eof; _test_eof72: cs = 72; goto _test_eof; _test_eof73: cs = 73; goto _test_eof; _test_eof74: cs = 74; goto _test_eof; _test_eof75: cs = 75; goto _test_eof; _test_eof76: cs = 76; goto _test_eof; _test_eof77: cs = 77; goto _test_eof; _test_eof78: cs = 78; goto _test_eof; _test_eof79: cs = 79; goto _test_eof; _test_eof80: cs = 80; goto _test_eof; _test_eof81: cs = 81; goto _test_eof; _test_eof82: cs = 82; goto _test_eof; _test_eof83: cs = 83; goto _test_eof; _test_eof84: cs = 84; goto _test_eof; _test_eof85: cs = 85; goto _test_eof; _test_eof86: cs = 86; goto _test_eof; _test_eof138: cs = 138; goto _test_eof; _test_eof139: cs = 139; goto _test_eof; _test_eof87: cs = 87; goto _test_eof; _test_eof88: cs = 88; goto _test_eof; _test_eof140: cs = 140; goto _test_eof; _test_eof89: cs = 89; goto _test_eof; _test_eof90: cs = 90; goto _test_eof; _test_eof141: cs = 141; goto _test_eof; _test_eof91: cs = 91; goto _test_eof; _test_eof92: cs = 92; goto _test_eof; _test_eof142: cs = 142; goto _test_eof; _test_eof93: cs = 93; goto _test_eof; _test_eof94: cs = 94; goto _test_eof; _test_eof95: cs = 95; goto _test_eof; _test_eof96: cs = 96; goto _test_eof; _test_eof143: cs = 143; goto _test_eof; _test_eof144: cs = 144; goto _test_eof; _test_eof145: cs = 145; goto _test_eof; _test_eof146: cs = 146; goto _test_eof; _test_eof147: cs = 147; goto _test_eof; _test_eof148: cs = 148; goto _test_eof; _test_eof149: cs = 149; goto _test_eof; _test_eof150: cs = 150; goto _test_eof; _test_eof: {} if ( p == eof ) { switch ( cs ) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: case 90: case 91: case 92: case 93: case 94: case 95: case 96: #line 7 "xmpp_lang.rl" { ret=0; } break; #line 2359 "xmpp_lang.c" } } _out: {} } #line 38 "xmpp_lang.rl" if (ret) return enif_make_atom(env, "true"); else return enif_make_atom(env, "false"); } static ErlNifFunc nif_funcs[] = { {"is_valid", 1, is_valid} }; ERL_NIF_INIT(xmpp_lang, nif_funcs, load, NULL, NULL, NULL) xmpp-1.4.4/c_src/jid.c0000644000232200023220000003470513610066730015070 0ustar debalancedebalance #line 1 "jid.rl" #include #include #line 28 "jid.rl" static const int jid_start = 1; static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { return 0; } static ERL_NIF_TERM mk_binary_term(ErlNifEnv* env, char *start, char *stop, int start_offset, int stop_offset) { ERL_NIF_TERM result; if (stop && start) { stop += stop_offset; start += start_offset; if (stop > start) { size_t size = stop - start; unsigned char *buf = enif_make_new_binary(env, size, &result); if (buf) { memcpy(buf, start, size); return result; } } } enif_make_new_binary(env, 0, &result); return result; } static ERL_NIF_TERM string_to_usr(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ErlNifBinary input; ERL_NIF_TERM node, domain, resource; int cs = 0, ret = 1; char *node_start = NULL; char *node_end = NULL; char *domain_start = NULL; char *domain_end = NULL; char *resource_start = NULL; char *resource_end = NULL; if (argc != 1) return enif_make_badarg(env); if (!(enif_inspect_binary(env, argv[0], &input))) return enif_make_badarg(env); if (!input.size) return enif_make_atom(env, "error"); char *p = (char *) input.data; char *pe = p + input.size; char *eof = pe; #line 67 "jid.c" { cs = jid_start; } #line 86 "jid.rl" #line 74 "jid.c" { if ( p == pe ) goto _test_eof; switch ( cs ) { case 1: switch( (*p) ) { case -32: goto tr2; case -19: goto tr4; case -16: goto tr5; case -12: goto tr7; case 32: goto tr0; case 34: goto tr9; case 46: goto tr10; case 47: goto tr0; case 58: goto tr9; case 60: goto tr9; case 62: goto tr9; case 64: goto tr0; } if ( (*p) < -15 ) { if ( (*p) < -62 ) { if ( (*p) <= -63 ) goto tr0; } else if ( (*p) > -33 ) { if ( -31 <= (*p) && (*p) <= -17 ) goto tr3; } else goto tr1; } else if ( (*p) > -13 ) { if ( (*p) < 9 ) { if ( -11 <= (*p) && (*p) <= -1 ) goto tr0; } else if ( (*p) > 13 ) { if ( 38 <= (*p) && (*p) <= 39 ) goto tr9; } else goto tr0; } else goto tr6; goto tr8; tr0: #line 15 "jid.rl" { ret = 0; } goto st0; #line 120 "jid.c" st0: cs = 0; goto _out; tr1: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } goto st2; st2: if ( ++p == pe ) goto _test_eof2; case 2: #line 134 "jid.c" if ( (*p) <= -65 ) goto tr11; goto tr0; tr8: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } #line 13 "jid.rl" { domain_end = p; } goto st33; tr11: #line 13 "jid.rl" { domain_end = p; } goto st33; st33: if ( ++p == pe ) goto _test_eof33; case 33: #line 154 "jid.c" switch( (*p) ) { case -32: goto st3; case -19: goto st5; case -16: goto st6; case -12: goto st8; case 32: goto tr0; case 34: goto tr14; case 46: goto tr47; case 47: goto tr48; case 58: goto tr14; case 60: goto tr14; case 62: goto tr14; case 64: goto tr33; } if ( (*p) < -15 ) { if ( (*p) < -62 ) { if ( (*p) <= -63 ) goto tr0; } else if ( (*p) > -33 ) { if ( -31 <= (*p) && (*p) <= -17 ) goto st4; } else goto st2; } else if ( (*p) > -13 ) { if ( (*p) < 9 ) { if ( -11 <= (*p) && (*p) <= -1 ) goto tr0; } else if ( (*p) > 13 ) { if ( 38 <= (*p) && (*p) <= 39 ) goto tr14; } else goto tr0; } else goto st7; goto tr11; tr2: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } goto st3; st3: if ( ++p == pe ) goto _test_eof3; case 3: #line 200 "jid.c" if ( -96 <= (*p) && (*p) <= -65 ) goto st2; goto tr0; tr3: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } goto st4; st4: if ( ++p == pe ) goto _test_eof4; case 4: #line 214 "jid.c" if ( (*p) <= -65 ) goto st2; goto tr0; tr4: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } goto st5; st5: if ( ++p == pe ) goto _test_eof5; case 5: #line 228 "jid.c" if ( (*p) <= -97 ) goto st2; goto tr0; tr5: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } goto st6; st6: if ( ++p == pe ) goto _test_eof6; case 6: #line 242 "jid.c" if ( -112 <= (*p) && (*p) <= -65 ) goto st4; goto tr0; tr6: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } goto st7; st7: if ( ++p == pe ) goto _test_eof7; case 7: #line 256 "jid.c" if ( (*p) <= -65 ) goto st4; goto tr0; tr7: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } goto st8; st8: if ( ++p == pe ) goto _test_eof8; case 8: #line 270 "jid.c" if ( (*p) <= -113 ) goto st4; goto tr0; tr9: #line 9 "jid.rl" { node_start = p; } #line 10 "jid.rl" { domain_start = p; } #line 13 "jid.rl" { domain_end = p; } goto st34; tr14: #line 13 "jid.rl" { domain_end = p; } goto st34; tr41: #line 10 "jid.rl" { domain_start = p; } #line 13 "jid.rl" { domain_end = p; } goto st34; st34: if ( ++p == pe ) goto _test_eof34; case 34: #line 296 "jid.c" switch( (*p) ) { case -32: goto st10; case -19: goto st12; case -16: goto st13; case -12: goto st15; case 32: goto tr0; case 46: goto tr54; case 47: goto tr48; case 64: goto tr0; } if ( (*p) < -31 ) { if ( (*p) > -63 ) { if ( -62 <= (*p) && (*p) <= -33 ) goto st9; } else goto tr0; } else if ( (*p) > -17 ) { if ( (*p) < -11 ) { if ( -15 <= (*p) && (*p) <= -13 ) goto st14; } else if ( (*p) > -1 ) { if ( 9 <= (*p) && (*p) <= 13 ) goto tr0; } else goto tr0; } else goto st11; goto tr14; tr34: #line 10 "jid.rl" { domain_start = p; } goto st9; st9: if ( ++p == pe ) goto _test_eof9; case 9: #line 333 "jid.c" if ( (*p) <= -65 ) goto tr14; goto tr0; tr35: #line 10 "jid.rl" { domain_start = p; } goto st10; st10: if ( ++p == pe ) goto _test_eof10; case 10: #line 345 "jid.c" if ( -96 <= (*p) && (*p) <= -65 ) goto st9; goto tr0; tr36: #line 10 "jid.rl" { domain_start = p; } goto st11; st11: if ( ++p == pe ) goto _test_eof11; case 11: #line 357 "jid.c" if ( (*p) <= -65 ) goto st9; goto tr0; tr37: #line 10 "jid.rl" { domain_start = p; } goto st12; st12: if ( ++p == pe ) goto _test_eof12; case 12: #line 369 "jid.c" if ( (*p) <= -97 ) goto st9; goto tr0; tr38: #line 10 "jid.rl" { domain_start = p; } goto st13; st13: if ( ++p == pe ) goto _test_eof13; case 13: #line 381 "jid.c" if ( -112 <= (*p) && (*p) <= -65 ) goto st11; goto tr0; tr39: #line 10 "jid.rl" { domain_start = p; } goto st14; st14: if ( ++p == pe ) goto _test_eof14; case 14: #line 393 "jid.c" if ( (*p) <= -65 ) goto st11; goto tr0; tr40: #line 10 "jid.rl" { domain_start = p; } goto st15; st15: if ( ++p == pe ) goto _test_eof15; case 15: #line 405 "jid.c" if ( (*p) <= -113 ) goto st11; goto tr0; tr54: #line 13 "jid.rl" { domain_end = p; } goto st35; st35: if ( ++p == pe ) goto _test_eof35; case 35: #line 417 "jid.c" switch( (*p) ) { case -32: goto st10; case -19: goto st12; case -16: goto st13; case -12: goto st15; case 32: goto tr0; case 46: goto tr0; case 47: goto tr48; case 64: goto tr0; } if ( (*p) < -31 ) { if ( (*p) > -63 ) { if ( -62 <= (*p) && (*p) <= -33 ) goto st9; } else goto tr0; } else if ( (*p) > -17 ) { if ( (*p) < -11 ) { if ( -15 <= (*p) && (*p) <= -13 ) goto st14; } else if ( (*p) > -1 ) { if ( 9 <= (*p) && (*p) <= 13 ) goto tr0; } else goto tr0; } else goto st11; goto tr14; tr48: #line 11 "jid.rl" { resource_start = p; } goto st16; st16: if ( ++p == pe ) goto _test_eof16; case 16: #line 454 "jid.c" switch( (*p) ) { case -32: goto st18; case -19: goto st20; case -16: goto st21; case -12: goto st23; } if ( (*p) < -31 ) { if ( (*p) > -63 ) { if ( -62 <= (*p) && (*p) <= -33 ) goto st17; } else goto tr0; } else if ( (*p) > -17 ) { if ( (*p) > -13 ) { if ( -11 <= (*p) && (*p) <= -1 ) goto tr0; } else if ( (*p) >= -15 ) goto st22; } else goto st19; goto tr24; st17: if ( ++p == pe ) goto _test_eof17; case 17: if ( (*p) <= -65 ) goto tr24; goto tr0; tr24: #line 14 "jid.rl" { resource_end = p; } goto st36; st36: if ( ++p == pe ) goto _test_eof36; case 36: #line 491 "jid.c" switch( (*p) ) { case -32: goto st18; case -19: goto st20; case -16: goto st21; case -12: goto st23; } if ( (*p) < -31 ) { if ( (*p) > -63 ) { if ( -62 <= (*p) && (*p) <= -33 ) goto st17; } else goto tr0; } else if ( (*p) > -17 ) { if ( (*p) > -13 ) { if ( -11 <= (*p) && (*p) <= -1 ) goto tr0; } else if ( (*p) >= -15 ) goto st22; } else goto st19; goto tr24; st18: if ( ++p == pe ) goto _test_eof18; case 18: if ( -96 <= (*p) && (*p) <= -65 ) goto st17; goto tr0; st19: if ( ++p == pe ) goto _test_eof19; case 19: if ( (*p) <= -65 ) goto st17; goto tr0; st20: if ( ++p == pe ) goto _test_eof20; case 20: if ( (*p) <= -97 ) goto st17; goto tr0; st21: if ( ++p == pe ) goto _test_eof21; case 21: if ( -112 <= (*p) && (*p) <= -65 ) goto st19; goto tr0; st22: if ( ++p == pe ) goto _test_eof22; case 22: if ( (*p) <= -65 ) goto st19; goto tr0; st23: if ( ++p == pe ) goto _test_eof23; case 23: if ( (*p) <= -113 ) goto st19; goto tr0; tr47: #line 13 "jid.rl" { domain_end = p; } goto st37; st37: if ( ++p == pe ) goto _test_eof37; case 37: #line 563 "jid.c" switch( (*p) ) { case -32: goto st3; case -19: goto st5; case -16: goto st6; case -12: goto st8; case 32: goto tr0; case 34: goto tr14; case 46: goto st24; case 47: goto tr48; case 58: goto tr14; case 60: goto tr14; case 62: goto tr14; case 64: goto tr33; } if ( (*p) < -15 ) { if ( (*p) < -62 ) { if ( (*p) <= -63 ) goto tr0; } else if ( (*p) > -33 ) { if ( -31 <= (*p) && (*p) <= -17 ) goto st4; } else goto st2; } else if ( (*p) > -13 ) { if ( (*p) < 9 ) { if ( -11 <= (*p) && (*p) <= -1 ) goto tr0; } else if ( (*p) > 13 ) { if ( 38 <= (*p) && (*p) <= 39 ) goto tr14; } else goto tr0; } else goto st7; goto tr11; tr10: #line 9 "jid.rl" { node_start = p; } goto st24; st24: if ( ++p == pe ) goto _test_eof24; case 24: #line 607 "jid.c" switch( (*p) ) { case -32: goto st26; case -19: goto st28; case -16: goto st29; case -12: goto st31; case 32: goto tr0; case 34: goto tr0; case 47: goto tr0; case 58: goto tr0; case 60: goto tr0; case 62: goto tr0; case 64: goto tr33; } if ( (*p) < -15 ) { if ( (*p) < -62 ) { if ( (*p) <= -63 ) goto tr0; } else if ( (*p) > -33 ) { if ( -31 <= (*p) && (*p) <= -17 ) goto st27; } else goto st25; } else if ( (*p) > -13 ) { if ( (*p) < 9 ) { if ( -11 <= (*p) && (*p) <= -1 ) goto tr0; } else if ( (*p) > 13 ) { if ( 38 <= (*p) && (*p) <= 39 ) goto tr0; } else goto tr0; } else goto st30; goto st24; st25: if ( ++p == pe ) goto _test_eof25; case 25: if ( (*p) <= -65 ) goto st24; goto tr0; st26: if ( ++p == pe ) goto _test_eof26; case 26: if ( -96 <= (*p) && (*p) <= -65 ) goto st25; goto tr0; st27: if ( ++p == pe ) goto _test_eof27; case 27: if ( (*p) <= -65 ) goto st25; goto tr0; st28: if ( ++p == pe ) goto _test_eof28; case 28: if ( (*p) <= -97 ) goto st25; goto tr0; st29: if ( ++p == pe ) goto _test_eof29; case 29: if ( -112 <= (*p) && (*p) <= -65 ) goto st27; goto tr0; st30: if ( ++p == pe ) goto _test_eof30; case 30: if ( (*p) <= -65 ) goto st27; goto tr0; st31: if ( ++p == pe ) goto _test_eof31; case 31: if ( (*p) <= -113 ) goto st27; goto tr0; tr33: #line 12 "jid.rl" { node_end = p; } goto st32; st32: if ( ++p == pe ) goto _test_eof32; case 32: #line 699 "jid.c" switch( (*p) ) { case -32: goto tr35; case -19: goto tr37; case -16: goto tr38; case -12: goto tr40; case 32: goto tr0; case 64: goto tr0; } if ( (*p) < -15 ) { if ( (*p) < -62 ) { if ( (*p) <= -63 ) goto tr0; } else if ( (*p) > -33 ) { if ( -31 <= (*p) && (*p) <= -17 ) goto tr36; } else goto tr34; } else if ( (*p) > -13 ) { if ( (*p) < 9 ) { if ( -11 <= (*p) && (*p) <= -1 ) goto tr0; } else if ( (*p) > 13 ) { if ( 46 <= (*p) && (*p) <= 47 ) goto tr0; } else goto tr0; } else goto tr39; goto tr41; } _test_eof2: cs = 2; goto _test_eof; _test_eof33: cs = 33; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof34: cs = 34; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; _test_eof10: cs = 10; goto _test_eof; _test_eof11: cs = 11; goto _test_eof; _test_eof12: cs = 12; goto _test_eof; _test_eof13: cs = 13; goto _test_eof; _test_eof14: cs = 14; goto _test_eof; _test_eof15: cs = 15; goto _test_eof; _test_eof35: cs = 35; goto _test_eof; _test_eof16: cs = 16; goto _test_eof; _test_eof17: cs = 17; goto _test_eof; _test_eof36: cs = 36; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; _test_eof20: cs = 20; goto _test_eof; _test_eof21: cs = 21; goto _test_eof; _test_eof22: cs = 22; goto _test_eof; _test_eof23: cs = 23; goto _test_eof; _test_eof37: cs = 37; goto _test_eof; _test_eof24: cs = 24; goto _test_eof; _test_eof25: cs = 25; goto _test_eof; _test_eof26: cs = 26; goto _test_eof; _test_eof27: cs = 27; goto _test_eof; _test_eof28: cs = 28; goto _test_eof; _test_eof29: cs = 29; goto _test_eof; _test_eof30: cs = 30; goto _test_eof; _test_eof31: cs = 31; goto _test_eof; _test_eof32: cs = 32; goto _test_eof; _test_eof: {} if ( p == eof ) { switch ( cs ) { case 33: case 34: case 35: case 37: #line 11 "jid.rl" { resource_start = p; } break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: #line 15 "jid.rl" { ret = 0; } break; #line 813 "jid.c" } } _out: {} } #line 87 "jid.rl" if (ret) { node = mk_binary_term(env, node_start, node_end, 0, 0); domain = mk_binary_term(env, domain_start, domain_end, 0, 1); resource = mk_binary_term(env, resource_start, resource_end, 1, 1); return enif_make_tuple3(env, node, domain, resource); } else { return enif_make_atom(env, "error"); } } static ErlNifFunc nif_funcs[] = { {"string_to_usr", 1, string_to_usr} }; ERL_NIF_INIT(jid, nif_funcs, load, NULL, NULL, NULL) xmpp-1.4.4/src/0000755000232200023220000000000013610066730013643 5ustar debalancedebalancexmpp-1.4.4/src/xmpp_stream_pkix.erl0000644000232200023220000002076413610066730017752 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_stream_pkix). %% API -export([authenticate/1, authenticate/2, get_cert_domains/1, format_error/1]). -include("xmpp.hrl"). -include_lib("public_key/include/public_key.hrl"). -include("XmppAddr.hrl"). -type cert() :: #'OTPCertificate'{}. %%%=================================================================== %%% API %%%=================================================================== -spec authenticate(xmpp_stream_in:state() | xmpp_stream_out:state()) -> {ok, binary()} | {error, atom(), binary()}. authenticate(State) -> authenticate(State, <<"">>). -spec authenticate(xmpp_stream_in:state() | xmpp_stream_out:state(), binary()) -> {ok, binary()} | {error, atom(), binary()}. authenticate(#{xmlns := ?NS_SERVER, socket := Socket} = State, Authzid) -> Peer = maps:get(remote_server, State, Authzid), case verify_server_cert(Peer, Socket) of ok -> {ok, Peer}; {error, Reason} -> {error, Reason, Peer} end; authenticate(#{xmlns := ?NS_CLIENT, stream_direction := out, socket := Socket, server := Server}, _) -> case verify_server_cert(Server, Socket) of ok -> {ok, Server}; {error, Reason} -> {error, Reason, Server} end; authenticate(#{xmlns := ?NS_CLIENT, stream_direction := in, socket := Socket, server := Server}, Authzid) -> JID = try jid:decode(Authzid) catch _:{bad_jid, <<>>} -> jid:make(Server); _:{bad_jid, _} -> {error, invalid_authzid, Authzid} end, case JID of #jid{user = User, lserver = LServer} -> case verify_cert(Socket) of {ok, Cert} -> JIDs = get_xmpp_addrs(Cert), get_username(JID, JIDs, LServer); {error, Reason} -> {error, Reason, User} end; Err -> Err end. format_error(idna_failed) -> {'bad-protocol', <<"Remote domain is not an IDN hostname">>}; format_error(hostname_mismatch) -> {'not-authorized', <<"Certificate host name mismatch">>}; format_error(jid_mismatch) -> {'not-authorized', <<"Certificate JID mismatch">>}; format_error(get_cert_failed) -> {'bad-protocol', <<"Failed to get peer certificate">>}; format_error(invalid_authzid) -> {'invalid-authzid', <<"Malformed JID">>}; format_error(Other) -> {'not-authorized', erlang:atom_to_binary(Other, utf8)}. -spec get_cert_domains(cert()) -> [binary()]. get_cert_domains(Cert) -> TBSCert = Cert#'OTPCertificate'.tbsCertificate, {rdnSequence, Subject} = TBSCert#'OTPTBSCertificate'.subject, Extensions = TBSCert#'OTPTBSCertificate'.extensions, get_domain_from_subject(lists:flatten(Subject)) ++ get_domains_from_san(Extensions). %%%=================================================================== %%% Internal functions %%%=================================================================== -spec verify_server_cert(binary(), xmpp_socket:socket()) -> ok | {error, atom()}. verify_server_cert(Server, Socket) -> case verify_cert(Socket) of {ok, Cert} -> try list_to_binary(idna:utf8_to_ascii(Server)) of AsciiServer -> case lists:any( fun(D) -> match_domain(AsciiServer, D) end, get_cert_domains(Cert)) of true -> ok; false -> {error, hostname_mismatch} end catch _:_ -> {error, idna_failed} end; {error, _} = Err -> Err end. -spec verify_cert(xmpp_socket:socket()) -> {ok, cert()} | {error, atom()}. verify_cert(Socket) -> case xmpp_socket:get_peer_certificate(Socket, otp) of {ok, Cert} -> case xmpp_socket:get_verify_result(Socket) of 0 -> {ok, Cert}; VerifyRes -> %% TODO: return atomic errors %% This should be improved in fast_tls Reason = fast_tls:get_cert_verify_string(VerifyRes, Cert), {error, erlang:binary_to_atom(Reason, utf8)} end; error -> {error, get_cert_failed} end. -spec get_domain_from_subject([#'AttributeTypeAndValue'{}]) -> [binary()]. get_domain_from_subject(AttrVals) -> case lists:keyfind(?'id-at-commonName', #'AttributeTypeAndValue'.type, AttrVals) of #'AttributeTypeAndValue'{value = {_, S}} -> try jid:decode(iolist_to_binary(S)) of #jid{luser = <<"">>, lresource = <<"">>, lserver = Domain} -> [Domain]; _ -> [] catch _:{bad_jid, _} -> [] end; _ -> [] end. -spec get_domains_from_san([#'Extension'{}] | asn1_NOVALUE) -> [binary()]. get_domains_from_san(Extensions) when is_list(Extensions) -> case lists:keyfind(?'id-ce-subjectAltName', #'Extension'.extnID, Extensions) of #'Extension'{extnValue = Vals} -> lists:flatmap( fun({dNSName, S}) -> [iolist_to_binary(S)]; ({otherName, AnotherName}) -> case decode_xmpp_addr(AnotherName) of {ok, #jid{luser = <<"">>, lresource = <<"">>, lserver = Domain}} -> try list_to_binary(idna:utf8_to_ascii(Domain)) catch _:_ -> [] end; _ -> [] end; (_) -> [] end, Vals); _ -> [] end; get_domains_from_san(_) -> []. -spec decode_xmpp_addr(#'AnotherName'{}) -> {ok, jid()} | error. decode_xmpp_addr(#'AnotherName'{'type-id' = ?'id-on-xmppAddr', value = XmppAddr}) -> try 'XmppAddr':decode('XmppAddr', XmppAddr) of {ok, JIDStr} -> try {ok, jid:decode(iolist_to_binary(JIDStr))} catch _:{bad_jid, _} -> error end; _ -> error catch _:_ -> error end; decode_xmpp_addr(_) -> error. -spec get_xmpp_addrs(cert()) -> [jid()]. get_xmpp_addrs(Cert) -> TBSCert = Cert#'OTPCertificate'.tbsCertificate, case TBSCert#'OTPTBSCertificate'.extensions of Extensions when is_list(Extensions) -> case lists:keyfind(?'id-ce-subjectAltName', #'Extension'.extnID, Extensions) of #'Extension'{extnValue = Vals} -> lists:flatmap( fun({otherName, AnotherName}) -> case decode_xmpp_addr(AnotherName) of {ok, JID} -> [JID]; _ -> [] end; (_) -> [] end, Vals); _ -> [] end; _ -> [] end. -spec get_username(jid(), [jid()], binary()) -> {ok, binary()} | {error, jid_mismatch, binary()}. get_username(#jid{user = User, lserver = LS}, _, LServer) when LS /= LServer -> %% The user provided JID from different domain {error, jid_mismatch, User}; get_username(#jid{user = <<>>}, [#jid{user = U, lserver = LS}], LServer) when U /= <<>> andalso LS == LServer -> %% The user didn't provide JID or username, and there is only %% one 'non-global' JID matching current domain {ok, U}; get_username(#jid{user = User}, [], _) when User /= <<>> -> %% The user provided username, but the certificate contains no JIDs %% We accept this since the certificate is verified {ok, User}; get_username(#jid{user = User, luser = LUser}, JIDs, LServer) when User /= <<>> -> %% The user provided username lists:foldl( fun(_, {ok, _} = OK) -> OK; (#jid{user = <<>>, lserver = LS}, _) when LS == LServer -> %% Found "global" JID in the certificate %% (i.e. in the form of 'domain.com') %% within current domain, so we force matching {ok, User}; (#jid{luser = LU, lserver = LS}, _) when LU == LUser, LS == LServer -> %% Found exact JID matching {ok, User}; (_, Err) -> Err end, {error, jid_mismatch, User}, JIDs); get_username(#jid{user = User}, _, _) -> %% Nothing from above is true {error, jid_mismatch, User}. -spec match_domain(binary(), binary()) -> boolean(). match_domain(Domain, Domain) -> true; match_domain(Domain, <<"*.", Rest/binary>>) -> %% RFC6120 states: %% DNS domain names in server certificates MAY contain the wildcard %% character '*' as the complete left-most label within the identifier case binary:split(Domain, <<$.>>) of [_, Rest] -> true; _ -> false end; match_domain(_, _) -> false. xmpp-1.4.4/src/xmpp_lang.erl0000644000232200023220000000372713610066730016345 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% Language tag processing library (see RFC5646) %%% @end %%% Created : 30 May 2018 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_lang). %% API -export([start/0, is_valid/1, check/1]). %%%=================================================================== %%% API %%%=================================================================== -spec start() -> ok | {error, unable_to_load_nif}. start() -> load_nif(p1_nif_utils:get_so_path(?MODULE, [xmpp_lang], "xmpp_lang")). load_nif(SOPath) -> case catch erlang:load_nif(SOPath, 0) of ok -> ok; {error, {reload, _}} -> ok; Err -> error_logger:warning_msg("unable to load xmpp_lang NIF: ~p~n", [Err]), {error, unable_to_load_nif} end. -spec is_valid(binary()) -> boolean(). is_valid(_) -> erlang:nif_error(nif_not_loaded). -spec check(binary()) -> binary(). check(<<>>) -> <<>>; check(S) -> case is_valid(S) of true -> S; false -> erlang:error({bad_lang, S}) end. %%%=================================================================== %%% Internal functions %%%=================================================================== xmpp-1.4.4/src/xep0261.erl0000644000232200023220000001130113610066730015450 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0261). -compile(export_all). do_decode(<<"transport">>, <<"urn:xmpp:jingle:transports:ibb:1">>, El, Opts) -> decode_jingle_ibb_transport(<<"urn:xmpp:jingle:transports:ibb:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"transport">>, <<"urn:xmpp:jingle:transports:ibb:1">>}]. do_encode({jingle_ibb_transport, _, _, _} = Transport, TopXMLNS) -> encode_jingle_ibb_transport(Transport, TopXMLNS). do_get_name({jingle_ibb_transport, _, _, _}) -> <<"transport">>. do_get_ns({jingle_ibb_transport, _, _, _}) -> <<"urn:xmpp:jingle:transports:ibb:1">>. pp(jingle_ibb_transport, 3) -> [sid, 'block-size', stanza]; pp(_, _) -> no. records() -> [{jingle_ibb_transport, 3}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). decode_jingle_ibb_transport(__TopXMLNS, __Opts, {xmlel, <<"transport">>, _attrs, _els}) -> {Sid, Block_size, Stanza} = decode_jingle_ibb_transport_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {jingle_ibb_transport, Sid, Block_size, Stanza}. decode_jingle_ibb_transport_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], _Sid, Block_size, Stanza) -> decode_jingle_ibb_transport_attrs(__TopXMLNS, _attrs, _val, Block_size, Stanza); decode_jingle_ibb_transport_attrs(__TopXMLNS, [{<<"block-size">>, _val} | _attrs], Sid, _Block_size, Stanza) -> decode_jingle_ibb_transport_attrs(__TopXMLNS, _attrs, Sid, _val, Stanza); decode_jingle_ibb_transport_attrs(__TopXMLNS, [{<<"stanza">>, _val} | _attrs], Sid, Block_size, _Stanza) -> decode_jingle_ibb_transport_attrs(__TopXMLNS, _attrs, Sid, Block_size, _val); decode_jingle_ibb_transport_attrs(__TopXMLNS, [_ | _attrs], Sid, Block_size, Stanza) -> decode_jingle_ibb_transport_attrs(__TopXMLNS, _attrs, Sid, Block_size, Stanza); decode_jingle_ibb_transport_attrs(__TopXMLNS, [], Sid, Block_size, Stanza) -> {decode_jingle_ibb_transport_attr_sid(__TopXMLNS, Sid), 'decode_jingle_ibb_transport_attr_block-size'(__TopXMLNS, Block_size), decode_jingle_ibb_transport_attr_stanza(__TopXMLNS, Stanza)}. encode_jingle_ibb_transport({jingle_ibb_transport, Sid, Block_size, Stanza}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:transports:ibb:1">>, [], __TopXMLNS), _els = [], _attrs = encode_jingle_ibb_transport_attr_stanza(Stanza, 'encode_jingle_ibb_transport_attr_block-size'(Block_size, encode_jingle_ibb_transport_attr_sid(Sid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"transport">>, _attrs, _els}. decode_jingle_ibb_transport_attr_sid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"sid">>, <<"transport">>, __TopXMLNS}}); decode_jingle_ibb_transport_attr_sid(__TopXMLNS, _val) -> _val. encode_jingle_ibb_transport_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. 'decode_jingle_ibb_transport_attr_block-size'(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"block-size">>, <<"transport">>, __TopXMLNS}}); 'decode_jingle_ibb_transport_attr_block-size'(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"block-size">>, <<"transport">>, __TopXMLNS}}); _res -> _res end. 'encode_jingle_ibb_transport_attr_block-size'(_val, _acc) -> [{<<"block-size">>, enc_int(_val)} | _acc]. decode_jingle_ibb_transport_attr_stanza(__TopXMLNS, undefined) -> iq; decode_jingle_ibb_transport_attr_stanza(__TopXMLNS, _val) -> case catch dec_enum(_val, [iq, message]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"stanza">>, <<"transport">>, __TopXMLNS}}); _res -> _res end. encode_jingle_ibb_transport_attr_stanza(iq, _acc) -> _acc; encode_jingle_ibb_transport_attr_stanza(_val, _acc) -> [{<<"stanza">>, enc_enum(_val)} | _acc]. xmpp-1.4.4/src/xmpp_util.erl0000644000232200023220000001215213610066730016371 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% %%% @end %%% Created : 12 Jul 2016 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_util). %% API -export([get_xdata_values/2, set_xdata_field/2, has_xdata_var/2, make_adhoc_response/1, make_adhoc_response/2, decode_timestamp/1, encode_timestamp/1]). -export([hex/1]). -include("xmpp.hrl"). %%%=================================================================== %%% API %%%=================================================================== -spec get_xdata_values(binary(), xdata()) -> [binary()]. get_xdata_values(Var, #xdata{fields = Fields}) -> case lists:keyfind(Var, #xdata_field.var, Fields) of #xdata_field{values = Vals} -> Vals; false -> [] end. -spec set_xdata_field(xdata_field(), xdata()) -> xdata(). set_xdata_field(Field, #xdata{fields = Fields} = X) -> NewFields = lists:keystore(Field#xdata_field.var, #xdata_field.var, Fields, Field), X#xdata{fields = NewFields}. -spec has_xdata_var(binary(), xdata()) -> boolean(). has_xdata_var(Var, #xdata{fields = Fields}) -> lists:keymember(Var, #xdata_field.var, Fields). -spec make_adhoc_response(adhoc_command(), adhoc_command()) -> adhoc_command(). make_adhoc_response(#adhoc_command{lang = Lang, node = Node, sid = SID}, Command) -> make_adhoc_response( Command#adhoc_command{lang = Lang, node = Node, sid = SID}). -spec make_adhoc_response(adhoc_command()) -> adhoc_command(). make_adhoc_response(#adhoc_command{sid = <<"">>, status = Status, actions = Actions} = Command) -> SID = encode_timestamp(p1_time_compat:timestamp()), NewActions = if Actions == undefined, Status /= completed -> #adhoc_actions{execute = complete, complete = true}; true -> undefined end, Command#adhoc_command{sid = SID, actions = NewActions}; make_adhoc_response(Command) -> Command. -spec decode_timestamp(binary()) -> erlang:timestamp(). decode_timestamp(S) -> try try_decode_timestamp(S) catch _:_ -> erlang:error({bad_timestamp, S}) end. -spec encode_timestamp(erlang:timestamp()) -> binary(). encode_timestamp({MegaSecs, Secs, MicroSecs}) -> {{Year, Month, Day}, {Hour, Minute, Second}} = calendar:now_to_universal_time({MegaSecs, Secs, MicroSecs}), Fraction = if MicroSecs > 0 -> io_lib:format(".~6..0B", [MicroSecs]); true -> "" end, list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT" "~2..0B:~2..0B:~2..0B~sZ", [Year, Month, Day, Hour, Minute, Second, Fraction])). -spec hex(binary()) -> binary(). hex(Bin) -> << <<(to_xchar(N div 16)), (to_xchar(N rem 16))>> || <> <= Bin >>. %%%=================================================================== %%% Internal functions %%%=================================================================== try_decode_timestamp(<>) -> Date = {to_integer(Y, 1970, 9999), to_integer(Mo, 1, 12), to_integer(D, 1, 31)}, Time = {to_integer(H, 0, 23), to_integer(Mi, 0, 59), to_integer(S, 0, 59)}, {MS, {TZH, TZM}} = try_decode_fraction(T), Seconds = calendar:datetime_to_gregorian_seconds({Date, Time}) - calendar:datetime_to_gregorian_seconds({{1970,1,1}, {0,0,0}}) - TZH * 60 * 60 - TZM * 60, {Seconds div 1000000, Seconds rem 1000000, MS}; try_decode_timestamp(<>) -> try_decode_timestamp(<>). try_decode_fraction(<<$., T/binary>>) -> {match, [V]} = re:run(T, <<"^[0-9]+">>, [{capture, [0], list}]), Size = length(V), <<_:Size/binary, TZD/binary>> = T, {list_to_integer(string:left(V, 6, $0)), try_decode_tzd(TZD)}; try_decode_fraction(TZD) -> {0, try_decode_tzd(TZD)}. try_decode_tzd(<<$Z>>) -> {0, 0}; try_decode_tzd(<<$-, H:2/binary, $:, M:2/binary>>) -> {-1 * to_integer(H, 0, 12), to_integer(M, 0, 59)}; try_decode_tzd(<<$+, H:2/binary, $:, M:2/binary>>) -> {to_integer(H, 0, 12), to_integer(M, 0, 59)}. to_integer(S, Min, Max) -> case binary_to_integer(S) of I when I >= Min, I =< Max -> I end. to_xchar(D) when (D >= 0) and (D < 10) -> D + $0; to_xchar(D) -> D + $a - 10. xmpp-1.4.4/src/rfc3921.erl0000644000232200023220000000555713610066730015454 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(rfc3921). -compile(export_all). do_decode(<<"session">>, <<"urn:ietf:params:xml:ns:xmpp-session">>, El, Opts) -> decode_session(<<"urn:ietf:params:xml:ns:xmpp-session">>, Opts, El); do_decode(<<"optional">>, <<"urn:ietf:params:xml:ns:xmpp-session">>, El, Opts) -> decode_session_optional(<<"urn:ietf:params:xml:ns:xmpp-session">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"session">>, <<"urn:ietf:params:xml:ns:xmpp-session">>}, {<<"optional">>, <<"urn:ietf:params:xml:ns:xmpp-session">>}]. do_encode({xmpp_session, _} = Session, TopXMLNS) -> encode_session(Session, TopXMLNS). do_get_name({xmpp_session, _}) -> <<"session">>. do_get_ns({xmpp_session, _}) -> <<"urn:ietf:params:xml:ns:xmpp-session">>. pp(xmpp_session, 1) -> [optional]; pp(_, _) -> no. records() -> [{xmpp_session, 1}]. decode_session(__TopXMLNS, __Opts, {xmlel, <<"session">>, _attrs, _els}) -> Optional = decode_session_els(__TopXMLNS, __Opts, _els, false), {xmpp_session, Optional}. decode_session_els(__TopXMLNS, __Opts, [], Optional) -> Optional; decode_session_els(__TopXMLNS, __Opts, [{xmlel, <<"optional">>, _attrs, _} = _el | _els], Optional) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-session">> -> decode_session_els(__TopXMLNS, __Opts, _els, decode_session_optional(<<"urn:ietf:params:xml:ns:xmpp-session">>, __Opts, _el)); _ -> decode_session_els(__TopXMLNS, __Opts, _els, Optional) end; decode_session_els(__TopXMLNS, __Opts, [_ | _els], Optional) -> decode_session_els(__TopXMLNS, __Opts, _els, Optional). encode_session({xmpp_session, Optional}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-session">>, [], __TopXMLNS), _els = lists:reverse('encode_session_$optional'(Optional, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"session">>, _attrs, _els}. 'encode_session_$optional'(false, __TopXMLNS, _acc) -> _acc; 'encode_session_$optional'(Optional, __TopXMLNS, _acc) -> [encode_session_optional(Optional, __TopXMLNS) | _acc]. decode_session_optional(__TopXMLNS, __Opts, {xmlel, <<"optional">>, _attrs, _els}) -> true. encode_session_optional(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-session">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"optional">>, _attrs, _els}. xmpp-1.4.4/src/xmpp_codec_external.erl0000644000232200023220000000034713610066730020376 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xmpp_codec_external). -compile(export_all). modules() -> []. lookup(_, _) -> undefined. lookup(Term) -> erlang:error(badarg, [Term]). xmpp-1.4.4/src/xep0153.erl0000644000232200023220000000707313610066730015463 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0153). -compile(export_all). do_decode(<<"x">>, <<"vcard-temp:x:update">>, El, Opts) -> decode_vcard_xupdate(<<"vcard-temp:x:update">>, Opts, El); do_decode(<<"photo">>, <<"vcard-temp:x:update">>, El, Opts) -> decode_vcard_xupdate_photo(<<"vcard-temp:x:update">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"x">>, <<"vcard-temp:x:update">>}, {<<"photo">>, <<"vcard-temp:x:update">>}]. do_encode({vcard_xupdate, _} = X, TopXMLNS) -> encode_vcard_xupdate(X, TopXMLNS). do_get_name({vcard_xupdate, _}) -> <<"x">>. do_get_ns({vcard_xupdate, _}) -> <<"vcard-temp:x:update">>. pp(vcard_xupdate, 1) -> [hash]; pp(_, _) -> no. records() -> [{vcard_xupdate, 1}]. decode_vcard_xupdate(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> Hash = decode_vcard_xupdate_els(__TopXMLNS, __Opts, _els, undefined), {vcard_xupdate, Hash}. decode_vcard_xupdate_els(__TopXMLNS, __Opts, [], Hash) -> Hash; decode_vcard_xupdate_els(__TopXMLNS, __Opts, [{xmlel, <<"photo">>, _attrs, _} = _el | _els], Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp:x:update">> -> decode_vcard_xupdate_els(__TopXMLNS, __Opts, _els, decode_vcard_xupdate_photo(<<"vcard-temp:x:update">>, __Opts, _el)); _ -> decode_vcard_xupdate_els(__TopXMLNS, __Opts, _els, Hash) end; decode_vcard_xupdate_els(__TopXMLNS, __Opts, [_ | _els], Hash) -> decode_vcard_xupdate_els(__TopXMLNS, __Opts, _els, Hash). encode_vcard_xupdate({vcard_xupdate, Hash}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp:x:update">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_xupdate_$hash'(Hash, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x">>, _attrs, _els}. 'encode_vcard_xupdate_$hash'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_xupdate_$hash'(Hash, __TopXMLNS, _acc) -> [encode_vcard_xupdate_photo(Hash, __TopXMLNS) | _acc]. decode_vcard_xupdate_photo(__TopXMLNS, __Opts, {xmlel, <<"photo">>, _attrs, _els}) -> Cdata = decode_vcard_xupdate_photo_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_xupdate_photo_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_xupdate_photo_cdata(__TopXMLNS, Cdata); decode_vcard_xupdate_photo_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_xupdate_photo_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_xupdate_photo_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_xupdate_photo_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_xupdate_photo(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp:x:update">>, [], __TopXMLNS), _els = encode_vcard_xupdate_photo_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"photo">>, _attrs, _els}. decode_vcard_xupdate_photo_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_xupdate_photo_cdata(__TopXMLNS, _val) -> _val. encode_vcard_xupdate_photo_cdata(<<>>, _acc) -> _acc; encode_vcard_xupdate_photo_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0084.erl0000644000232200023220000004051713610066730015466 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0084). -compile(export_all). do_decode(<<"metadata">>, <<"urn:xmpp:avatar:metadata">>, El, Opts) -> decode_avatar_meta(<<"urn:xmpp:avatar:metadata">>, Opts, El); do_decode(<<"pointer">>, <<"urn:xmpp:avatar:metadata">>, El, Opts) -> decode_avatar_pointer(<<"urn:xmpp:avatar:metadata">>, Opts, El); do_decode(<<"info">>, <<"urn:xmpp:avatar:metadata">>, El, Opts) -> decode_avatar_info(<<"urn:xmpp:avatar:metadata">>, Opts, El); do_decode(<<"data">>, <<"urn:xmpp:avatar:data">>, El, Opts) -> decode_avatar_data(<<"urn:xmpp:avatar:data">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"metadata">>, <<"urn:xmpp:avatar:metadata">>}, {<<"pointer">>, <<"urn:xmpp:avatar:metadata">>}, {<<"info">>, <<"urn:xmpp:avatar:metadata">>}, {<<"data">>, <<"urn:xmpp:avatar:data">>}]. do_encode({avatar_data, _} = Data, TopXMLNS) -> encode_avatar_data(Data, TopXMLNS); do_encode({avatar_info, _, _, _, _, _, _} = Info, TopXMLNS) -> encode_avatar_info(Info, TopXMLNS); do_encode({avatar_pointer, _, _, _, _, _, _} = Pointer, TopXMLNS) -> encode_avatar_pointer(Pointer, TopXMLNS); do_encode({avatar_meta, _, _} = Metadata, TopXMLNS) -> encode_avatar_meta(Metadata, TopXMLNS). do_get_name({avatar_data, _}) -> <<"data">>; do_get_name({avatar_info, _, _, _, _, _, _}) -> <<"info">>; do_get_name({avatar_meta, _, _}) -> <<"metadata">>; do_get_name({avatar_pointer, _, _, _, _, _, _}) -> <<"pointer">>. do_get_ns({avatar_data, _}) -> <<"urn:xmpp:avatar:data">>; do_get_ns({avatar_info, _, _, _, _, _, _}) -> <<"urn:xmpp:avatar:metadata">>; do_get_ns({avatar_meta, _, _}) -> <<"urn:xmpp:avatar:metadata">>; do_get_ns({avatar_pointer, _, _, _, _, _, _}) -> <<"urn:xmpp:avatar:metadata">>. get_els({avatar_pointer, _bytes, _id, _type, _height, _width, _sub_els}) -> _sub_els. set_els({avatar_pointer, _bytes, _id, _type, _height, _width, _}, _sub_els) -> {avatar_pointer, _bytes, _id, _type, _height, _width, _sub_els}. pp(avatar_data, 1) -> [data]; pp(avatar_info, 6) -> [bytes, id, type, height, width, url]; pp(avatar_pointer, 6) -> [bytes, id, type, height, width, sub_els]; pp(avatar_meta, 2) -> [info, pointer]; pp(_, _) -> no. records() -> [{avatar_data, 1}, {avatar_info, 6}, {avatar_pointer, 6}, {avatar_meta, 2}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_avatar_meta(__TopXMLNS, __Opts, {xmlel, <<"metadata">>, _attrs, _els}) -> {Pointer, Info} = decode_avatar_meta_els(__TopXMLNS, __Opts, _els, undefined, []), {avatar_meta, Info, Pointer}. decode_avatar_meta_els(__TopXMLNS, __Opts, [], Pointer, Info) -> {Pointer, lists:reverse(Info)}; decode_avatar_meta_els(__TopXMLNS, __Opts, [{xmlel, <<"info">>, _attrs, _} = _el | _els], Pointer, Info) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:avatar:metadata">> -> decode_avatar_meta_els(__TopXMLNS, __Opts, _els, Pointer, [decode_avatar_info(<<"urn:xmpp:avatar:metadata">>, __Opts, _el) | Info]); _ -> decode_avatar_meta_els(__TopXMLNS, __Opts, _els, Pointer, Info) end; decode_avatar_meta_els(__TopXMLNS, __Opts, [{xmlel, <<"pointer">>, _attrs, _} = _el | _els], Pointer, Info) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:avatar:metadata">> -> decode_avatar_meta_els(__TopXMLNS, __Opts, _els, decode_avatar_pointer(<<"urn:xmpp:avatar:metadata">>, __Opts, _el), Info); _ -> decode_avatar_meta_els(__TopXMLNS, __Opts, _els, Pointer, Info) end; decode_avatar_meta_els(__TopXMLNS, __Opts, [_ | _els], Pointer, Info) -> decode_avatar_meta_els(__TopXMLNS, __Opts, _els, Pointer, Info). encode_avatar_meta({avatar_meta, Info, Pointer}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:avatar:metadata">>, [], __TopXMLNS), _els = lists:reverse('encode_avatar_meta_$pointer'(Pointer, __NewTopXMLNS, 'encode_avatar_meta_$info'(Info, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"metadata">>, _attrs, _els}. 'encode_avatar_meta_$pointer'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_avatar_meta_$pointer'(Pointer, __TopXMLNS, _acc) -> [encode_avatar_pointer(Pointer, __TopXMLNS) | _acc]. 'encode_avatar_meta_$info'([], __TopXMLNS, _acc) -> _acc; 'encode_avatar_meta_$info'([Info | _els], __TopXMLNS, _acc) -> 'encode_avatar_meta_$info'(_els, __TopXMLNS, [encode_avatar_info(Info, __TopXMLNS) | _acc]). decode_avatar_pointer(__TopXMLNS, __Opts, {xmlel, <<"pointer">>, _attrs, _els}) -> __Els = decode_avatar_pointer_els(__TopXMLNS, __Opts, _els, []), {Bytes, Id, Type, Height, Width} = decode_avatar_pointer_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {avatar_pointer, Bytes, Id, Type, Height, Width, __Els}. decode_avatar_pointer_els(__TopXMLNS, __Opts, [], __Els) -> lists:reverse(__Els); decode_avatar_pointer_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], __Els) -> decode_avatar_pointer_els(__TopXMLNS, __Opts, _els, [_el | __Els]); decode_avatar_pointer_els(__TopXMLNS, __Opts, [_ | _els], __Els) -> decode_avatar_pointer_els(__TopXMLNS, __Opts, _els, __Els). decode_avatar_pointer_attrs(__TopXMLNS, [{<<"bytes">>, _val} | _attrs], _Bytes, Id, Type, Height, Width) -> decode_avatar_pointer_attrs(__TopXMLNS, _attrs, _val, Id, Type, Height, Width); decode_avatar_pointer_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], Bytes, _Id, Type, Height, Width) -> decode_avatar_pointer_attrs(__TopXMLNS, _attrs, Bytes, _val, Type, Height, Width); decode_avatar_pointer_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Bytes, Id, _Type, Height, Width) -> decode_avatar_pointer_attrs(__TopXMLNS, _attrs, Bytes, Id, _val, Height, Width); decode_avatar_pointer_attrs(__TopXMLNS, [{<<"height">>, _val} | _attrs], Bytes, Id, Type, _Height, Width) -> decode_avatar_pointer_attrs(__TopXMLNS, _attrs, Bytes, Id, Type, _val, Width); decode_avatar_pointer_attrs(__TopXMLNS, [{<<"width">>, _val} | _attrs], Bytes, Id, Type, Height, _Width) -> decode_avatar_pointer_attrs(__TopXMLNS, _attrs, Bytes, Id, Type, Height, _val); decode_avatar_pointer_attrs(__TopXMLNS, [_ | _attrs], Bytes, Id, Type, Height, Width) -> decode_avatar_pointer_attrs(__TopXMLNS, _attrs, Bytes, Id, Type, Height, Width); decode_avatar_pointer_attrs(__TopXMLNS, [], Bytes, Id, Type, Height, Width) -> {decode_avatar_pointer_attr_bytes(__TopXMLNS, Bytes), decode_avatar_pointer_attr_id(__TopXMLNS, Id), decode_avatar_pointer_attr_type(__TopXMLNS, Type), decode_avatar_pointer_attr_height(__TopXMLNS, Height), decode_avatar_pointer_attr_width(__TopXMLNS, Width)}. encode_avatar_pointer({avatar_pointer, Bytes, Id, Type, Height, Width, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:avatar:metadata">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els], _attrs = encode_avatar_pointer_attr_width(Width, encode_avatar_pointer_attr_height(Height, encode_avatar_pointer_attr_type(Type, encode_avatar_pointer_attr_id(Id, encode_avatar_pointer_attr_bytes(Bytes, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"pointer">>, _attrs, _els}. decode_avatar_pointer_attr_bytes(__TopXMLNS, undefined) -> undefined; decode_avatar_pointer_attr_bytes(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"bytes">>, <<"pointer">>, __TopXMLNS}}); _res -> _res end. encode_avatar_pointer_attr_bytes(undefined, _acc) -> _acc; encode_avatar_pointer_attr_bytes(_val, _acc) -> [{<<"bytes">>, enc_int(_val)} | _acc]. decode_avatar_pointer_attr_id(__TopXMLNS, undefined) -> <<>>; decode_avatar_pointer_attr_id(__TopXMLNS, _val) -> _val. encode_avatar_pointer_attr_id(<<>>, _acc) -> _acc; encode_avatar_pointer_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_avatar_pointer_attr_type(__TopXMLNS, undefined) -> <<>>; decode_avatar_pointer_attr_type(__TopXMLNS, _val) -> _val. encode_avatar_pointer_attr_type(<<>>, _acc) -> _acc; encode_avatar_pointer_attr_type(_val, _acc) -> [{<<"type">>, _val} | _acc]. decode_avatar_pointer_attr_height(__TopXMLNS, undefined) -> undefined; decode_avatar_pointer_attr_height(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"height">>, <<"pointer">>, __TopXMLNS}}); _res -> _res end. encode_avatar_pointer_attr_height(undefined, _acc) -> _acc; encode_avatar_pointer_attr_height(_val, _acc) -> [{<<"height">>, enc_int(_val)} | _acc]. decode_avatar_pointer_attr_width(__TopXMLNS, undefined) -> undefined; decode_avatar_pointer_attr_width(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"width">>, <<"pointer">>, __TopXMLNS}}); _res -> _res end. encode_avatar_pointer_attr_width(undefined, _acc) -> _acc; encode_avatar_pointer_attr_width(_val, _acc) -> [{<<"width">>, enc_int(_val)} | _acc]. decode_avatar_info(__TopXMLNS, __Opts, {xmlel, <<"info">>, _attrs, _els}) -> {Bytes, Id, Type, Url, Height, Width} = decode_avatar_info_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined, undefined), {avatar_info, Bytes, Id, Type, Height, Width, Url}. decode_avatar_info_attrs(__TopXMLNS, [{<<"bytes">>, _val} | _attrs], _Bytes, Id, Type, Url, Height, Width) -> decode_avatar_info_attrs(__TopXMLNS, _attrs, _val, Id, Type, Url, Height, Width); decode_avatar_info_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], Bytes, _Id, Type, Url, Height, Width) -> decode_avatar_info_attrs(__TopXMLNS, _attrs, Bytes, _val, Type, Url, Height, Width); decode_avatar_info_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Bytes, Id, _Type, Url, Height, Width) -> decode_avatar_info_attrs(__TopXMLNS, _attrs, Bytes, Id, _val, Url, Height, Width); decode_avatar_info_attrs(__TopXMLNS, [{<<"url">>, _val} | _attrs], Bytes, Id, Type, _Url, Height, Width) -> decode_avatar_info_attrs(__TopXMLNS, _attrs, Bytes, Id, Type, _val, Height, Width); decode_avatar_info_attrs(__TopXMLNS, [{<<"height">>, _val} | _attrs], Bytes, Id, Type, Url, _Height, Width) -> decode_avatar_info_attrs(__TopXMLNS, _attrs, Bytes, Id, Type, Url, _val, Width); decode_avatar_info_attrs(__TopXMLNS, [{<<"width">>, _val} | _attrs], Bytes, Id, Type, Url, Height, _Width) -> decode_avatar_info_attrs(__TopXMLNS, _attrs, Bytes, Id, Type, Url, Height, _val); decode_avatar_info_attrs(__TopXMLNS, [_ | _attrs], Bytes, Id, Type, Url, Height, Width) -> decode_avatar_info_attrs(__TopXMLNS, _attrs, Bytes, Id, Type, Url, Height, Width); decode_avatar_info_attrs(__TopXMLNS, [], Bytes, Id, Type, Url, Height, Width) -> {decode_avatar_info_attr_bytes(__TopXMLNS, Bytes), decode_avatar_info_attr_id(__TopXMLNS, Id), decode_avatar_info_attr_type(__TopXMLNS, Type), decode_avatar_info_attr_url(__TopXMLNS, Url), decode_avatar_info_attr_height(__TopXMLNS, Height), decode_avatar_info_attr_width(__TopXMLNS, Width)}. encode_avatar_info({avatar_info, Bytes, Id, Type, Height, Width, Url}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:avatar:metadata">>, [], __TopXMLNS), _els = [], _attrs = encode_avatar_info_attr_width(Width, encode_avatar_info_attr_height(Height, encode_avatar_info_attr_url(Url, encode_avatar_info_attr_type(Type, encode_avatar_info_attr_id(Id, encode_avatar_info_attr_bytes(Bytes, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))))), {xmlel, <<"info">>, _attrs, _els}. decode_avatar_info_attr_bytes(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"bytes">>, <<"info">>, __TopXMLNS}}); decode_avatar_info_attr_bytes(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"bytes">>, <<"info">>, __TopXMLNS}}); _res -> _res end. encode_avatar_info_attr_bytes(_val, _acc) -> [{<<"bytes">>, enc_int(_val)} | _acc]. decode_avatar_info_attr_id(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"id">>, <<"info">>, __TopXMLNS}}); decode_avatar_info_attr_id(__TopXMLNS, _val) -> _val. encode_avatar_info_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_avatar_info_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"info">>, __TopXMLNS}}); decode_avatar_info_attr_type(__TopXMLNS, _val) -> _val. encode_avatar_info_attr_type(_val, _acc) -> [{<<"type">>, _val} | _acc]. decode_avatar_info_attr_url(__TopXMLNS, undefined) -> <<>>; decode_avatar_info_attr_url(__TopXMLNS, _val) -> _val. encode_avatar_info_attr_url(<<>>, _acc) -> _acc; encode_avatar_info_attr_url(_val, _acc) -> [{<<"url">>, _val} | _acc]. decode_avatar_info_attr_height(__TopXMLNS, undefined) -> undefined; decode_avatar_info_attr_height(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"height">>, <<"info">>, __TopXMLNS}}); _res -> _res end. encode_avatar_info_attr_height(undefined, _acc) -> _acc; encode_avatar_info_attr_height(_val, _acc) -> [{<<"height">>, enc_int(_val)} | _acc]. decode_avatar_info_attr_width(__TopXMLNS, undefined) -> undefined; decode_avatar_info_attr_width(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"width">>, <<"info">>, __TopXMLNS}}); _res -> _res end. encode_avatar_info_attr_width(undefined, _acc) -> _acc; encode_avatar_info_attr_width(_val, _acc) -> [{<<"width">>, enc_int(_val)} | _acc]. decode_avatar_data(__TopXMLNS, __Opts, {xmlel, <<"data">>, _attrs, _els}) -> Data = decode_avatar_data_els(__TopXMLNS, __Opts, _els, <<>>), {avatar_data, Data}. decode_avatar_data_els(__TopXMLNS, __Opts, [], Data) -> decode_avatar_data_cdata(__TopXMLNS, Data); decode_avatar_data_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_avatar_data_els(__TopXMLNS, __Opts, _els, <>); decode_avatar_data_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_avatar_data_els(__TopXMLNS, __Opts, _els, Data). encode_avatar_data({avatar_data, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:avatar:data">>, [], __TopXMLNS), _els = encode_avatar_data_cdata(Data, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"data">>, _attrs, _els}. decode_avatar_data_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"data">>, __TopXMLNS}}); decode_avatar_data_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"data">>, __TopXMLNS}}); _res -> _res end. encode_avatar_data_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. xmpp-1.4.4/src/xep0078.erl0000644000232200023220000002714413610066730015472 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0078). -compile(export_all). do_decode(<<"auth">>, <<"http://jabber.org/features/iq-auth">>, El, Opts) -> decode_legacy_auth_feature(<<"http://jabber.org/features/iq-auth">>, Opts, El); do_decode(<<"query">>, <<"jabber:iq:auth">>, El, Opts) -> decode_legacy_auth(<<"jabber:iq:auth">>, Opts, El); do_decode(<<"resource">>, <<"jabber:iq:auth">>, El, Opts) -> decode_legacy_auth_resource(<<"jabber:iq:auth">>, Opts, El); do_decode(<<"digest">>, <<"jabber:iq:auth">>, El, Opts) -> decode_legacy_auth_digest(<<"jabber:iq:auth">>, Opts, El); do_decode(<<"password">>, <<"jabber:iq:auth">>, El, Opts) -> decode_legacy_auth_password(<<"jabber:iq:auth">>, Opts, El); do_decode(<<"username">>, <<"jabber:iq:auth">>, El, Opts) -> decode_legacy_auth_username(<<"jabber:iq:auth">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"auth">>, <<"http://jabber.org/features/iq-auth">>}, {<<"query">>, <<"jabber:iq:auth">>}, {<<"resource">>, <<"jabber:iq:auth">>}, {<<"digest">>, <<"jabber:iq:auth">>}, {<<"password">>, <<"jabber:iq:auth">>}, {<<"username">>, <<"jabber:iq:auth">>}]. do_encode({legacy_auth, _, _, _, _} = Query, TopXMLNS) -> encode_legacy_auth(Query, TopXMLNS); do_encode({legacy_auth_feature} = Auth, TopXMLNS) -> encode_legacy_auth_feature(Auth, TopXMLNS). do_get_name({legacy_auth, _, _, _, _}) -> <<"query">>; do_get_name({legacy_auth_feature}) -> <<"auth">>. do_get_ns({legacy_auth, _, _, _, _}) -> <<"jabber:iq:auth">>; do_get_ns({legacy_auth_feature}) -> <<"http://jabber.org/features/iq-auth">>. pp(legacy_auth, 4) -> [username, password, digest, resource]; pp(legacy_auth_feature, 0) -> []; pp(_, _) -> no. records() -> [{legacy_auth, 4}, {legacy_auth_feature, 0}]. decode_legacy_auth_feature(__TopXMLNS, __Opts, {xmlel, <<"auth">>, _attrs, _els}) -> {legacy_auth_feature}. encode_legacy_auth_feature({legacy_auth_feature}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/features/iq-auth">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"auth">>, _attrs, _els}. decode_legacy_auth(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Digest, Password, Resource, Username} = decode_legacy_auth_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined), {legacy_auth, Username, Password, Digest, Resource}. decode_legacy_auth_els(__TopXMLNS, __Opts, [], Digest, Password, Resource, Username) -> {Digest, Password, Resource, Username}; decode_legacy_auth_els(__TopXMLNS, __Opts, [{xmlel, <<"username">>, _attrs, _} = _el | _els], Digest, Password, Resource, Username) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:auth">> -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, Password, Resource, decode_legacy_auth_username(<<"jabber:iq:auth">>, __Opts, _el)); _ -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, Password, Resource, Username) end; decode_legacy_auth_els(__TopXMLNS, __Opts, [{xmlel, <<"password">>, _attrs, _} = _el | _els], Digest, Password, Resource, Username) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:auth">> -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, decode_legacy_auth_password(<<"jabber:iq:auth">>, __Opts, _el), Resource, Username); _ -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, Password, Resource, Username) end; decode_legacy_auth_els(__TopXMLNS, __Opts, [{xmlel, <<"digest">>, _attrs, _} = _el | _els], Digest, Password, Resource, Username) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:auth">> -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, decode_legacy_auth_digest(<<"jabber:iq:auth">>, __Opts, _el), Password, Resource, Username); _ -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, Password, Resource, Username) end; decode_legacy_auth_els(__TopXMLNS, __Opts, [{xmlel, <<"resource">>, _attrs, _} = _el | _els], Digest, Password, Resource, Username) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:auth">> -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, Password, decode_legacy_auth_resource(<<"jabber:iq:auth">>, __Opts, _el), Username); _ -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, Password, Resource, Username) end; decode_legacy_auth_els(__TopXMLNS, __Opts, [_ | _els], Digest, Password, Resource, Username) -> decode_legacy_auth_els(__TopXMLNS, __Opts, _els, Digest, Password, Resource, Username). encode_legacy_auth({legacy_auth, Username, Password, Digest, Resource}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:auth">>, [], __TopXMLNS), _els = lists:reverse('encode_legacy_auth_$digest'(Digest, __NewTopXMLNS, 'encode_legacy_auth_$password'(Password, __NewTopXMLNS, 'encode_legacy_auth_$resource'(Resource, __NewTopXMLNS, 'encode_legacy_auth_$username'(Username, __NewTopXMLNS, []))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. 'encode_legacy_auth_$digest'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_legacy_auth_$digest'(Digest, __TopXMLNS, _acc) -> [encode_legacy_auth_digest(Digest, __TopXMLNS) | _acc]. 'encode_legacy_auth_$password'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_legacy_auth_$password'(Password, __TopXMLNS, _acc) -> [encode_legacy_auth_password(Password, __TopXMLNS) | _acc]. 'encode_legacy_auth_$resource'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_legacy_auth_$resource'(Resource, __TopXMLNS, _acc) -> [encode_legacy_auth_resource(Resource, __TopXMLNS) | _acc]. 'encode_legacy_auth_$username'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_legacy_auth_$username'(Username, __TopXMLNS, _acc) -> [encode_legacy_auth_username(Username, __TopXMLNS) | _acc]. decode_legacy_auth_resource(__TopXMLNS, __Opts, {xmlel, <<"resource">>, _attrs, _els}) -> Cdata = decode_legacy_auth_resource_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_legacy_auth_resource_els(__TopXMLNS, __Opts, [], Cdata) -> decode_legacy_auth_resource_cdata(__TopXMLNS, Cdata); decode_legacy_auth_resource_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_legacy_auth_resource_els(__TopXMLNS, __Opts, _els, <>); decode_legacy_auth_resource_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_legacy_auth_resource_els(__TopXMLNS, __Opts, _els, Cdata). encode_legacy_auth_resource(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:auth">>, [], __TopXMLNS), _els = encode_legacy_auth_resource_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"resource">>, _attrs, _els}. decode_legacy_auth_resource_cdata(__TopXMLNS, <<>>) -> <<>>; decode_legacy_auth_resource_cdata(__TopXMLNS, _val) -> _val. encode_legacy_auth_resource_cdata(<<>>, _acc) -> _acc; encode_legacy_auth_resource_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_legacy_auth_digest(__TopXMLNS, __Opts, {xmlel, <<"digest">>, _attrs, _els}) -> Cdata = decode_legacy_auth_digest_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_legacy_auth_digest_els(__TopXMLNS, __Opts, [], Cdata) -> decode_legacy_auth_digest_cdata(__TopXMLNS, Cdata); decode_legacy_auth_digest_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_legacy_auth_digest_els(__TopXMLNS, __Opts, _els, <>); decode_legacy_auth_digest_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_legacy_auth_digest_els(__TopXMLNS, __Opts, _els, Cdata). encode_legacy_auth_digest(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:auth">>, [], __TopXMLNS), _els = encode_legacy_auth_digest_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"digest">>, _attrs, _els}. decode_legacy_auth_digest_cdata(__TopXMLNS, <<>>) -> <<>>; decode_legacy_auth_digest_cdata(__TopXMLNS, _val) -> _val. encode_legacy_auth_digest_cdata(<<>>, _acc) -> _acc; encode_legacy_auth_digest_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_legacy_auth_password(__TopXMLNS, __Opts, {xmlel, <<"password">>, _attrs, _els}) -> Cdata = decode_legacy_auth_password_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_legacy_auth_password_els(__TopXMLNS, __Opts, [], Cdata) -> decode_legacy_auth_password_cdata(__TopXMLNS, Cdata); decode_legacy_auth_password_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_legacy_auth_password_els(__TopXMLNS, __Opts, _els, <>); decode_legacy_auth_password_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_legacy_auth_password_els(__TopXMLNS, __Opts, _els, Cdata). encode_legacy_auth_password(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:auth">>, [], __TopXMLNS), _els = encode_legacy_auth_password_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"password">>, _attrs, _els}. decode_legacy_auth_password_cdata(__TopXMLNS, <<>>) -> <<>>; decode_legacy_auth_password_cdata(__TopXMLNS, _val) -> _val. encode_legacy_auth_password_cdata(<<>>, _acc) -> _acc; encode_legacy_auth_password_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_legacy_auth_username(__TopXMLNS, __Opts, {xmlel, <<"username">>, _attrs, _els}) -> Cdata = decode_legacy_auth_username_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_legacy_auth_username_els(__TopXMLNS, __Opts, [], Cdata) -> decode_legacy_auth_username_cdata(__TopXMLNS, Cdata); decode_legacy_auth_username_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_legacy_auth_username_els(__TopXMLNS, __Opts, _els, <>); decode_legacy_auth_username_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_legacy_auth_username_els(__TopXMLNS, __Opts, _els, Cdata). encode_legacy_auth_username(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:auth">>, [], __TopXMLNS), _els = encode_legacy_auth_username_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"username">>, _attrs, _els}. decode_legacy_auth_username_cdata(__TopXMLNS, <<>>) -> <<>>; decode_legacy_auth_username_cdata(__TopXMLNS, _val) -> _val. encode_legacy_auth_username_cdata(<<>>, _acc) -> _acc; encode_legacy_auth_username_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0172.erl0000644000232200023220000000344313610066730015461 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0172). -compile(export_all). do_decode(<<"nick">>, <<"http://jabber.org/protocol/nick">>, El, Opts) -> decode_nick(<<"http://jabber.org/protocol/nick">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"nick">>, <<"http://jabber.org/protocol/nick">>}]. do_encode({nick, _} = Nick, TopXMLNS) -> encode_nick(Nick, TopXMLNS). do_get_name({nick, _}) -> <<"nick">>. do_get_ns({nick, _}) -> <<"http://jabber.org/protocol/nick">>. pp(nick, 1) -> [name]; pp(_, _) -> no. records() -> [{nick, 1}]. decode_nick(__TopXMLNS, __Opts, {xmlel, <<"nick">>, _attrs, _els}) -> Name = decode_nick_els(__TopXMLNS, __Opts, _els, <<>>), {nick, Name}. decode_nick_els(__TopXMLNS, __Opts, [], Name) -> decode_nick_cdata(__TopXMLNS, Name); decode_nick_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Name) -> decode_nick_els(__TopXMLNS, __Opts, _els, <>); decode_nick_els(__TopXMLNS, __Opts, [_ | _els], Name) -> decode_nick_els(__TopXMLNS, __Opts, _els, Name). encode_nick({nick, Name}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/nick">>, [], __TopXMLNS), _els = encode_nick_cdata(Name, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"nick">>, _attrs, _els}. decode_nick_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"nick">>, __TopXMLNS}}); decode_nick_cdata(__TopXMLNS, _val) -> _val. encode_nick_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0377.erl0000644000232200023220000001604213610066730015467 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0377). -compile(export_all). do_decode(<<"report">>, <<"urn:xmpp:reporting:0">>, El, Opts) -> decode_report(<<"urn:xmpp:reporting:0">>, Opts, El); do_decode(<<"text">>, <<"urn:xmpp:reporting:0">>, El, Opts) -> decode_report_text(<<"urn:xmpp:reporting:0">>, Opts, El); do_decode(<<"spam">>, <<"urn:xmpp:reporting:0">>, El, Opts) -> decode_report_reason_spam(<<"urn:xmpp:reporting:0">>, Opts, El); do_decode(<<"abuse">>, <<"urn:xmpp:reporting:0">>, El, Opts) -> decode_report_reason_abuse(<<"urn:xmpp:reporting:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"report">>, <<"urn:xmpp:reporting:0">>}, {<<"text">>, <<"urn:xmpp:reporting:0">>}, {<<"spam">>, <<"urn:xmpp:reporting:0">>}, {<<"abuse">>, <<"urn:xmpp:reporting:0">>}]. do_encode({text, _, _} = Text, TopXMLNS) -> encode_report_text(Text, TopXMLNS); do_encode({report, _, _} = Report, TopXMLNS) -> encode_report(Report, TopXMLNS). do_get_name({report, _, _}) -> <<"report">>; do_get_name({text, _, _}) -> <<"text">>. do_get_ns({report, _, _}) -> <<"urn:xmpp:reporting:0">>; do_get_ns({text, _, _}) -> <<"urn:xmpp:reporting:0">>. pp(text, 2) -> [lang, data]; pp(report, 2) -> [reason, text]; pp(_, _) -> no. records() -> [{text, 2}, {report, 2}]. decode_report(__TopXMLNS, __Opts, {xmlel, <<"report">>, _attrs, _els}) -> {Text, Reason} = decode_report_els(__TopXMLNS, __Opts, _els, [], undefined), {report, Reason, Text}. decode_report_els(__TopXMLNS, __Opts, [], Text, Reason) -> {lists:reverse(Text), Reason}; decode_report_els(__TopXMLNS, __Opts, [{xmlel, <<"abuse">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:reporting:0">> -> decode_report_els(__TopXMLNS, __Opts, _els, Text, decode_report_reason_abuse(<<"urn:xmpp:reporting:0">>, __Opts, _el)); _ -> decode_report_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_report_els(__TopXMLNS, __Opts, [{xmlel, <<"spam">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:reporting:0">> -> decode_report_els(__TopXMLNS, __Opts, _els, Text, decode_report_reason_spam(<<"urn:xmpp:reporting:0">>, __Opts, _el)); _ -> decode_report_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_report_els(__TopXMLNS, __Opts, [{xmlel, <<"text">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:reporting:0">> -> decode_report_els(__TopXMLNS, __Opts, _els, [decode_report_text(<<"urn:xmpp:reporting:0">>, __Opts, _el) | Text], Reason); _ -> decode_report_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_report_els(__TopXMLNS, __Opts, [_ | _els], Text, Reason) -> decode_report_els(__TopXMLNS, __Opts, _els, Text, Reason). encode_report({report, Reason, Text}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:reporting:0">>, [], __TopXMLNS), _els = lists:reverse('encode_report_$text'(Text, __NewTopXMLNS, 'encode_report_$reason'(Reason, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"report">>, _attrs, _els}. 'encode_report_$text'([], __TopXMLNS, _acc) -> _acc; 'encode_report_$text'([Text | _els], __TopXMLNS, _acc) -> 'encode_report_$text'(_els, __TopXMLNS, [encode_report_text(Text, __TopXMLNS) | _acc]). 'encode_report_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_report_$reason'(abuse = Reason, __TopXMLNS, _acc) -> [encode_report_reason_abuse(Reason, __TopXMLNS) | _acc]; 'encode_report_$reason'(spam = Reason, __TopXMLNS, _acc) -> [encode_report_reason_spam(Reason, __TopXMLNS) | _acc]. decode_report_text(__TopXMLNS, __Opts, {xmlel, <<"text">>, _attrs, _els}) -> Data = decode_report_text_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_report_text_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_report_text_els(__TopXMLNS, __Opts, [], Data) -> decode_report_text_cdata(__TopXMLNS, Data); decode_report_text_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_report_text_els(__TopXMLNS, __Opts, _els, <>); decode_report_text_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_report_text_els(__TopXMLNS, __Opts, _els, Data). decode_report_text_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_report_text_attrs(__TopXMLNS, _attrs, _val); decode_report_text_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_report_text_attrs(__TopXMLNS, _attrs, Lang); decode_report_text_attrs(__TopXMLNS, [], Lang) -> 'decode_report_text_attr_xml:lang'(__TopXMLNS, Lang). encode_report_text({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:reporting:0">>, [], __TopXMLNS), _els = encode_report_text_cdata(Data, []), _attrs = 'encode_report_text_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"text">>, _attrs, _els}. 'decode_report_text_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_report_text_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"text">>, __TopXMLNS}}); _res -> _res end. 'encode_report_text_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_report_text_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_report_text_cdata(__TopXMLNS, <<>>) -> <<>>; decode_report_text_cdata(__TopXMLNS, _val) -> _val. encode_report_text_cdata(<<>>, _acc) -> _acc; encode_report_text_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_report_reason_spam(__TopXMLNS, __Opts, {xmlel, <<"spam">>, _attrs, _els}) -> spam. encode_report_reason_spam(spam, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:reporting:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"spam">>, _attrs, _els}. decode_report_reason_abuse(__TopXMLNS, __Opts, {xmlel, <<"abuse">>, _attrs, _els}) -> abuse. encode_report_reason_abuse(abuse, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:reporting:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"abuse">>, _attrs, _els}. xmpp-1.4.4/src/scram.erl0000644000232200023220000000470213610066730015457 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Stephen Röttger %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(scram). -author('stephen.roettger@googlemail.com'). %% External exports %% SASLPREP is not implemented, so we use the similar RESOURCEPREP instead -export([salted_password/3, stored_key/1, server_key/1, server_signature/2, client_signature/2, client_key/1, client_key/2]). -spec salted_password(binary(), binary(), non_neg_integer()) -> binary(). salted_password(Password, Salt, IterationCount) -> hi(jid:resourceprep(Password), Salt, IterationCount). -spec client_key(binary()) -> binary(). client_key(SaltedPassword) -> sha_mac(SaltedPassword, <<"Client Key">>). -spec stored_key(binary()) -> binary(). stored_key(ClientKey) -> crypto:hash(sha, ClientKey). -spec server_key(binary()) -> binary(). server_key(SaltedPassword) -> sha_mac(SaltedPassword, <<"Server Key">>). -spec client_signature(binary(), binary()) -> binary(). client_signature(StoredKey, AuthMessage) -> sha_mac(StoredKey, AuthMessage). -spec client_key(binary(), binary()) -> binary(). client_key(ClientProof, ClientSignature) -> crypto:exor(ClientProof, ClientSignature). -spec server_signature(binary(), binary()) -> binary(). server_signature(ServerKey, AuthMessage) -> sha_mac(ServerKey, AuthMessage). hi(Password, Salt, IterationCount) -> U1 = sha_mac(Password, <>), crypto:exor(U1, hi_round(Password, U1, IterationCount - 1)). hi_round(Password, UPrev, 1) -> sha_mac(Password, UPrev); hi_round(Password, UPrev, IterationCount) -> U = sha_mac(Password, UPrev), crypto:exor(U, hi_round(Password, U, IterationCount - 1)). sha_mac(Key, Data) -> crypto:hmac(sha, Key, Data). xmpp-1.4.4/src/xmpp_stream_in.erl0000644000232200023220000013067213610066730017405 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_stream_in). -define(GEN_SERVER, p1_server). -behaviour(?GEN_SERVER). -protocol({rfc, 6120}). -protocol({xep, 114, '1.6'}). %% API -export([start/3, start_link/3, call/3, cast/2, reply/2, stop/1, accept/1, send/2, close/1, close/2, send_error/3, establish/1, get_transport/1, change_shaper/2, set_timeout/2, format_error/1, send_ws_ping/1]). %% gen_server callbacks -export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3]). %%-define(DBGFSM, true). -ifdef(DBGFSM). -define(FSMOPTS, [{debug, [trace]}]). -else. -define(FSMOPTS, []). -endif. -include("xmpp.hrl"). -type state() :: #{owner := pid(), mod := module(), socket := xmpp_socket:socket(), socket_mod => xmpp_socket:sockmod(), socket_opts => [proplists:property()], socket_monitor => reference(), stream_timeout := {integer(), integer()} | infinity, stream_state := stream_state(), stream_direction => in | out, stream_id => binary(), stream_header_sent => boolean(), stream_restarted => boolean(), stream_compressed => boolean(), stream_encrypted => boolean(), stream_version => {non_neg_integer(), non_neg_integer()}, stream_authenticated => boolean(), ip => {inet:ip_address(), inet:port_number()}, codec_options => [xmpp:decode_option()], xmlns => binary(), lang => binary(), user => binary(), server => binary(), resource => binary(), lserver => binary(), remote_server => binary(), sasl_mech => binary(), sasl_state => xmpp_sasl:sasl_state(), _ => _}. -type stream_state() :: accepting | wait_for_stream | wait_for_handshake | wait_for_starttls | wait_for_sasl_request | wait_for_sasl_response | wait_for_bind | established | disconnected. -type stop_reason() :: {stream, reset | {in | out, stream_error()}} | {tls, inet:posix() | atom() | binary()} | {socket, inet:posix() | atom()} | internal_failure. -type noreply() :: {noreply, state(), timeout()}. -type next_state() :: noreply() | {stop, term(), state()}. -export_type([state/0, stop_reason/0]). -callback init(list()) -> {ok, state()} | {error, term()} | ignore. -callback handle_cast(term(), state()) -> state(). -callback handle_call(term(), term(), state()) -> state(). -callback handle_info(term(), state()) -> state(). -callback terminate(term(), state()) -> any(). -callback code_change(term(), state(), term()) -> {ok, state()} | {error, term()}. -callback handle_stream_start(stream_start(), state()) -> state(). -callback handle_stream_established(state()) -> state(). -callback handle_stream_end(stop_reason(), state()) -> state(). -callback handle_cdata(binary(), state()) -> state(). -callback handle_unauthenticated_packet(xmpp_element(), state()) -> state(). -callback handle_authenticated_packet(xmpp_element(), state()) -> state(). -callback handle_unbinded_packet(xmpp_element(), state()) -> state(). -callback handle_auth_success(binary(), binary(), module(), state()) -> state(). -callback handle_auth_failure(binary(), binary(), binary(), state()) -> state(). -callback handle_send(xmpp_element(), ok | {error, inet:posix()}, state()) -> state(). -callback handle_recv(fxml:xmlel(), xmpp_element() | {error, term()}, state()) -> state(). -callback handle_timeout(state()) -> state(). -callback get_password_fun(state()) -> fun(). -callback get_password_fun(xmpp_sasl:mechanism(), state()) -> fun(). -callback check_password_fun(xmpp_sasl:mechanism(), state()) -> fun(). -callback check_password_digest_fun(xmpp_sasl:mechanism(), state()) -> fun(). -callback bind(binary(), state()) -> {ok, state()} | {error, stanza_error(), state()}. -callback compress_methods(state()) -> [binary()]. -callback tls_options(state()) -> [proplists:property()]. -callback tls_required(state()) -> boolean(). -callback tls_enabled(state()) -> boolean(). -callback sasl_mechanisms([xmpp_sasl:mechanism()], state()) -> [xmpp_sasl:mechanism()]. -callback unauthenticated_stream_features(state()) -> [xmpp_element()]. -callback authenticated_stream_features(state()) -> [xmpp_element()]. %% All callbacks are optional -optional_callbacks([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3, handle_stream_start/2, handle_stream_established/1, handle_stream_end/2, handle_cdata/2, handle_authenticated_packet/2, handle_unauthenticated_packet/2, handle_unbinded_packet/2, handle_auth_success/4, handle_auth_failure/4, handle_send/3, handle_recv/3, handle_timeout/1, get_password_fun/1, get_password_fun/2, check_password_fun/2, check_password_digest_fun/2, bind/2, compress_methods/1, tls_options/1, tls_required/1, tls_enabled/1, sasl_mechanisms/2, unauthenticated_stream_features/1, authenticated_stream_features/1]). %%%=================================================================== %%% API %%%=================================================================== start(Mod, Args, Opts) -> ?GEN_SERVER:start(?MODULE, [Mod|Args], Opts ++ ?FSMOPTS). start_link(Mod, Args, Opts) -> ?GEN_SERVER:start_link(?MODULE, [Mod|Args], Opts ++ ?FSMOPTS). call(Ref, Msg, Timeout) -> ?GEN_SERVER:call(Ref, Msg, Timeout). cast(Ref, Msg) -> ?GEN_SERVER:cast(Ref, Msg). reply(Ref, Reply) -> ?GEN_SERVER:reply(Ref, Reply). -spec stop(pid()) -> ok; (state()) -> no_return(). stop(Pid) when is_pid(Pid) -> cast(Pid, stop); stop(#{owner := Owner} = State) when Owner == self() -> terminate(normal, State), try erlang:nif_error(normal) catch _:_ -> exit(normal) end; stop(_) -> erlang:error(badarg). -spec accept(pid()) -> ok. accept(Pid) -> cast(Pid, accept). -spec send(pid(), xmpp_element()) -> ok; (state(), xmpp_element()) -> state(). send(Pid, Pkt) when is_pid(Pid) -> cast(Pid, {send, Pkt}); send(#{owner := Owner} = State, Pkt) when Owner == self() -> send_pkt(State, Pkt); send(_, _) -> erlang:error(badarg). -spec send_ws_ping(pid()) -> ok; (state()) -> state(). send_ws_ping(Pid) when is_pid(Pid) -> cast(Pid, send_ws_ping); send_ws_ping(#{owner := Owner, socket := Sock, stream_header_sent := true} = State) when Owner == self() -> case xmpp_socket:send_ws_ping(Sock) of ok -> State; {error, Why} -> process_stream_end({socket, Why}, State) end; send_ws_ping(State) -> State. -spec close(pid()) -> ok; (state()) -> state(). close(Pid) when is_pid(Pid) -> close(Pid, closed); close(#{owner := Owner} = State) when Owner == self() -> close_socket(State); close(_) -> erlang:error(badarg). -spec close(pid(), atom()) -> ok. close(Pid, Reason) -> cast(Pid, {close, Reason}). -spec establish(state()) -> state(). establish(State) -> process_stream_established(State). -spec set_timeout(state(), non_neg_integer() | infinity) -> state(). set_timeout(#{owner := Owner} = State, Timeout) when Owner == self() -> case Timeout of infinity -> State#{stream_timeout => infinity}; _ -> Time = p1_time_compat:monotonic_time(milli_seconds), State#{stream_timeout => {Timeout, Time}} end; set_timeout(_, _) -> erlang:error(badarg). -spec get_transport(state()) -> atom(). get_transport(#{socket := Socket, owner := Owner}) when Owner == self() -> xmpp_socket:get_transport(Socket); get_transport(_) -> erlang:error(badarg). -spec change_shaper(state(), none | p1_shaper:state()) -> state(). change_shaper(#{socket := Socket, owner := Owner} = State, Shaper) when Owner == self() -> Socket1 = xmpp_socket:change_shaper(Socket, Shaper), State#{socket => Socket1}; change_shaper(_, _) -> erlang:error(badarg). -spec format_error(stop_reason()) -> binary(). format_error({socket, Reason}) -> format("Connection failed: ~s", [format_inet_error(Reason)]); format_error({stream, reset}) -> <<"Stream reset by peer">>; format_error({stream, {in, #stream_error{} = Err}}) -> format("Stream closed by peer: ~s", [xmpp:format_stream_error(Err)]); format_error({stream, {out, #stream_error{} = Err}}) -> format("Stream closed by local host: ~s", [xmpp:format_stream_error(Err)]); format_error({tls, Reason}) -> format("TLS failed: ~s", [format_tls_error(Reason)]); format_error(internal_failure) -> <<"Internal server error">>; format_error(Err) -> format("Unrecognized error: ~w", [Err]). %%%=================================================================== %%% gen_server callbacks %%%=================================================================== init([Mod, {SockMod, Socket}, Opts]) -> Time = p1_time_compat:monotonic_time(milli_seconds), Timeout = timer:seconds(30), State = #{owner => self(), mod => Mod, socket => Socket, socket_mod => SockMod, socket_opts => Opts, stream_timeout => {Timeout, Time}, stream_state => accepting}, {ok, State, Timeout}. -spec handle_cast(term(), state()) -> next_state(). handle_cast(accept, #{socket := Socket, socket_mod := SockMod, socket_opts := Opts} = State) -> XMPPSocket = xmpp_socket:new(SockMod, Socket, Opts), SocketMonitor = xmpp_socket:monitor(XMPPSocket), case xmpp_socket:peername(XMPPSocket) of {ok, IP} -> State1 = maps:remove(socket_mod, State), State2 = maps:remove(socket_opts, State1), State3 = State2#{socket => XMPPSocket, socket_monitor => SocketMonitor, ip => IP}, State4 = init_state(State3, Opts), case is_disconnected(State4) of true -> noreply(State4); false -> handle_info({tcp, Socket, <<>>}, State4) end; {error, _} -> stop(State) end; handle_cast({send, Pkt}, State) -> noreply(send_pkt(State, Pkt)); handle_cast(send_ws_ping, State) -> noreply(send_ws_ping(State)); handle_cast(stop, State) -> {stop, normal, State}; handle_cast({close, Reason}, State) -> State1 = close_socket(State), noreply( case is_disconnected(State) of true -> State1; false -> process_stream_end({socket, Reason}, State) end); handle_cast(Cast, State) -> noreply(try callback(handle_cast, Cast, State) catch _:{?MODULE, undef} -> State end). -spec handle_call(term(), term(), state()) -> next_state(). handle_call(Call, From, State) -> noreply(try callback(handle_call, Call, From, State) catch _:{?MODULE, undef} -> State end). -spec handle_info(term(), state()) -> next_state(). handle_info(_, #{stream_state := accepting} = State) -> stop(State); handle_info({'$gen_event', {xmlstreamstart, Name, Attrs}}, #{stream_state := wait_for_stream, xmlns := XMLNS, lang := MyLang} = State) -> El = #xmlel{name = Name, attrs = Attrs}, noreply( try xmpp:decode(El, XMLNS, []) of #stream_start{} = Pkt -> State1 = send_header(State, Pkt), case is_disconnected(State1) of true -> State1; false -> process_stream(Pkt, State1) end; _ -> State1 = send_header(State), case is_disconnected(State1) of true -> State1; false -> send_pkt(State1, xmpp:serr_invalid_xml()) end catch _:{xmpp_codec, Why} -> State1 = send_header(State), case is_disconnected(State1) of true -> State1; false -> Txt = xmpp:io_format_error(Why), Lang = select_lang(MyLang, xmpp:get_lang(El)), Err = xmpp:serr_invalid_xml(Txt, Lang), send_pkt(State1, Err) end end); handle_info({'$gen_event', {xmlstreamend, _}}, State) -> noreply(process_stream_end({stream, reset}, State)); handle_info({'$gen_event', closed}, State) -> noreply(process_stream_end({socket, closed}, State)); handle_info({'$gen_event', {xmlstreamerror, Reason}}, #{lang := Lang}= State) -> State1 = send_header(State), noreply( case is_disconnected(State1) of true -> State1; false -> Err = case Reason of <<"XML stanza is too big">> -> xmpp:serr_policy_violation(Reason, Lang); {_, Txt} -> xmpp:serr_not_well_formed(Txt, Lang) end, send_pkt(State1, Err) end); handle_info({'$gen_event', El}, #{stream_state := wait_for_stream} = State) -> error_logger:warning_msg("unexpected event from XML driver: ~p; " "xmlstreamstart was expected", [El]), State1 = send_header(State), noreply( case is_disconnected(State1) of true -> State1; false -> send_pkt(State1, xmpp:serr_invalid_xml()) end); handle_info({'$gen_event', {xmlstreamelement, El}}, #{xmlns := NS, codec_options := Opts} = State) -> noreply( try xmpp:decode(El, NS, Opts) of Pkt -> State1 = try callback(handle_recv, El, Pkt, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> process_element(Pkt, State1) end catch _:{xmpp_codec, Why} -> State1 = try callback(handle_recv, El, {error, Why}, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> process_invalid_xml(State1, El, Why) end end); handle_info({'$gen_all_state_event', {xmlstreamcdata, Data}}, State) -> noreply(try callback(handle_cdata, Data, State) catch _:{?MODULE, undef} -> State end); handle_info(timeout, #{lang := Lang} = State) -> Disconnected = is_disconnected(State), noreply(try callback(handle_timeout, State) catch _:{?MODULE, undef} when not Disconnected -> Txt = <<"Idle connection">>, send_pkt(State, xmpp:serr_connection_timeout(Txt, Lang)); _:{?MODULE, undef} -> stop(State) end); handle_info({'DOWN', MRef, _Type, _Object, _Info}, #{socket_monitor := MRef} = State) -> noreply(process_stream_end({socket, closed}, State)); handle_info({tcp, _, Data}, #{socket := Socket} = State) -> noreply( case xmpp_socket:recv(Socket, Data) of {ok, NewSocket} -> State#{socket => NewSocket}; {error, Reason} when is_atom(Reason) -> process_stream_end({socket, Reason}, State); {error, Reason} -> %% TODO: make fast_tls return atoms process_stream_end({tls, Reason}, State) end); handle_info({tcp_closed, _}, State) -> handle_info({'$gen_event', closed}, State); handle_info({tcp_error, _, Reason}, State) -> noreply(process_stream_end({socket, Reason}, State)); handle_info(Info, State) -> noreply(try callback(handle_info, Info, State) catch _:{?MODULE, undef} -> State end). -spec terminate(term(), state()) -> state(). terminate(_, #{stream_state := accepting} = State) -> State; terminate(Reason, State) -> case get(already_terminated) of true -> State; _ -> put(already_terminated, true), try callback(terminate, Reason, State) catch _:{?MODULE, undef} -> ok end, send_trailer(State) end. -spec code_change(term(), state(), term()) -> {ok, state()} | {error, term()}. code_change(OldVsn, State, Extra) -> callback(code_change, OldVsn, State, Extra). %%%=================================================================== %%% Internal functions %%%=================================================================== -spec init_state(state(), [proplists:property()]) -> state(). init_state(#{socket := Socket, mod := Mod} = State, Opts) -> Encrypted = proplists:get_bool(tls, Opts), State1 = State#{stream_direction => in, stream_id => xmpp_stream:new_id(), stream_state => wait_for_stream, stream_header_sent => false, stream_restarted => false, stream_compressed => false, stream_encrypted => Encrypted, stream_version => {1,0}, stream_authenticated => false, codec_options => [ignore_els], xmlns => ?NS_CLIENT, lang => <<"">>, user => <<"">>, server => <<"">>, resource => <<"">>, lserver => <<"">>}, case try Mod:init([State1, Opts]) catch _:undef -> {ok, State1} end of {ok, State2} when not Encrypted -> State2; {ok, State2} when Encrypted -> TLSOpts = try callback(tls_options, State2) catch _:{?MODULE, undef} -> [] end, case xmpp_socket:starttls(Socket, TLSOpts) of {ok, TLSSocket} -> State2#{socket => TLSSocket}; {error, Reason} -> process_stream_end({tls, Reason}, State2) end; {error, Reason} -> process_stream_end(Reason, State1); ignore -> stop(State) end. -spec noreply(state()) -> noreply(). noreply(#{stream_timeout := infinity} = State) -> {noreply, State, infinity}; noreply(#{stream_timeout := {MSecs, StartTime}} = State) -> CurrentTime = p1_time_compat:monotonic_time(milli_seconds), Timeout = max(0, MSecs - CurrentTime + StartTime), {noreply, State, Timeout}. -spec is_disconnected(state()) -> boolean(). is_disconnected(#{stream_state := StreamState}) -> StreamState == disconnected. -spec process_invalid_xml(state(), fxml:xmlel(), term()) -> state(). process_invalid_xml(#{lang := MyLang} = State, El, Reason) -> case xmpp:is_stanza(El) of true -> Txt = xmpp:io_format_error(Reason), Lang = select_lang(MyLang, xmpp:get_lang(El)), send_error(State, El, xmpp:err_bad_request(Txt, Lang)); false -> case {xmpp:get_name(El), xmpp:get_ns(El)} of {Tag, ?NS_SASL} when Tag == <<"auth">>; Tag == <<"response">>; Tag == <<"abort">> -> Txt = xmpp:io_format_error(Reason), Err = #sasl_failure{reason = 'malformed-request', text = xmpp:mk_text(Txt, MyLang)}, send_pkt(State, Err); {<<"starttls">>, ?NS_TLS} -> send_pkt(State, #starttls_failure{}); {<<"compress">>, ?NS_COMPRESS} -> Err = #compress_failure{reason = 'setup-failed'}, send_pkt(State, Err); _ -> %% Maybe add something more? State end end. -spec process_stream_end(stop_reason(), state()) -> state(). process_stream_end(_, #{stream_state := disconnected} = State) -> State; process_stream_end(Reason, State) -> State1 = State#{stream_timeout => infinity, stream_state => disconnected}, try callback(handle_stream_end, Reason, State1) catch _:{?MODULE, undef} -> stop(State1) end. -spec process_stream(stream_start(), state()) -> state(). process_stream(#stream_start{xmlns = XML_NS, stream_xmlns = STREAM_NS}, #{xmlns := NS} = State) when XML_NS /= NS; STREAM_NS /= ?NS_STREAM -> send_pkt(State, xmpp:serr_invalid_namespace()); process_stream(#stream_start{version = {N, _}}, State) when N > 1 -> send_pkt(State, xmpp:serr_unsupported_version()); process_stream(#stream_start{lang = Lang}, #{xmlns := ?NS_CLIENT, lang := DefaultLang} = State) when size(Lang) > 35 -> %% As stated in BCP47, 4.4.1: %% Protocols or specifications that specify limited buffer sizes for %% language tags MUST allow for language tags of at least 35 characters. %% Do not store long language tag to avoid possible DoS/flood attacks Txt = <<"Too long value of 'xml:lang' attribute">>, send_pkt(State, xmpp:serr_policy_violation(Txt, DefaultLang)); process_stream(#stream_start{to = undefined, version = Version} = StreamStart, #{lang := Lang, server := Server, xmlns := NS} = State) -> if Version < {1,0} andalso NS /= ?NS_COMPONENT -> %% Work-around for gmail servers To = jid:make(Server), process_stream(StreamStart#stream_start{to = To}, State); true -> Txt = <<"Missing 'to' attribute">>, send_pkt(State, xmpp:serr_improper_addressing(Txt, Lang)) end; process_stream(#stream_start{to = #jid{luser = U, lresource = R}}, #{lang := Lang} = State) when U /= <<"">>; R /= <<"">> -> Txt = <<"Improper 'to' attribute">>, send_pkt(State, xmpp:serr_improper_addressing(Txt, Lang)); process_stream(#stream_start{to = #jid{lserver = RemoteServer}} = StreamStart, #{xmlns := ?NS_COMPONENT} = State) -> State1 = State#{remote_server => RemoteServer, stream_state => wait_for_handshake}, try callback(handle_stream_start, StreamStart, State1) catch _:{?MODULE, undef} -> State1 end; process_stream(#stream_start{to = #jid{server = Server, lserver = LServer}, from = From} = StreamStart, #{stream_authenticated := Authenticated, stream_restarted := StreamWasRestarted, xmlns := NS, resource := Resource, stream_encrypted := Encrypted} = State) -> State1 = if not StreamWasRestarted -> State#{server => Server, lserver => LServer}; true -> State end, State2 = case From of #jid{lserver = RemoteServer} when NS == ?NS_SERVER -> State1#{remote_server => RemoteServer}; _ -> State1 end, State3 = try callback(handle_stream_start, StreamStart, State2) catch _:{?MODULE, undef} -> State2 end, case is_disconnected(State3) of true -> State3; false -> State4 = send_features(State3), case is_disconnected(State4) of true -> State4; false -> TLSRequired = is_starttls_required(State4), if not Authenticated and (TLSRequired and not Encrypted) -> State4#{stream_state => wait_for_starttls}; not Authenticated -> State4#{stream_state => wait_for_sasl_request}; (NS == ?NS_CLIENT) and (Resource == <<"">>) -> State4#{stream_state => wait_for_bind}; true -> process_stream_established(State4) end end end. -spec process_element(xmpp_element(), state()) -> state(). process_element(Pkt, #{stream_state := StateName, lang := Lang} = State) -> case Pkt of #starttls{} when StateName == wait_for_starttls; StateName == wait_for_sasl_request -> process_starttls(State); #starttls{} -> process_starttls_failure(unexpected_starttls_request, State); #sasl_auth{} when StateName == wait_for_starttls -> send_pkt(State, #sasl_failure{reason = 'encryption-required'}); #sasl_auth{} when StateName == wait_for_sasl_request -> process_sasl_request(Pkt, State); #sasl_auth{} when StateName == wait_for_sasl_response -> process_sasl_request(Pkt, maps:remove(sasl_state, State)); #sasl_auth{} -> Txt = <<"SASL negotiation is not allowed in this state">>, send_pkt(State, #sasl_failure{reason = 'not-authorized', text = xmpp:mk_text(Txt, Lang)}); #sasl_response{} when StateName == wait_for_starttls -> send_pkt(State, #sasl_failure{reason = 'encryption-required'}); #sasl_response{} when StateName == wait_for_sasl_response -> process_sasl_response(Pkt, State); #sasl_response{} -> Txt = <<"SASL negotiation is not allowed in this state">>, send_pkt(State, #sasl_failure{reason = 'not-authorized', text = xmpp:mk_text(Txt, Lang)}); #sasl_abort{} when StateName == wait_for_sasl_response -> process_sasl_abort(State); #sasl_abort{} -> send_pkt(State, #sasl_failure{reason = 'aborted'}); #sasl_success{} -> State; #compress{} -> process_compress(Pkt, State); #handshake{} when StateName == wait_for_handshake -> process_handshake(Pkt, State); #handshake{} -> State; #stream_error{} -> process_stream_end({stream, {in, Pkt}}, State); _ when StateName == wait_for_sasl_request; StateName == wait_for_handshake; StateName == wait_for_sasl_response -> process_unauthenticated_packet(Pkt, State); _ when StateName == wait_for_starttls -> Txt = <<"Use of STARTTLS required">>, Err = xmpp:serr_policy_violation(Txt, Lang), send_pkt(State, Err); _ when StateName == wait_for_bind -> process_bind(Pkt, State); _ when StateName == established -> process_authenticated_packet(Pkt, State) end. -spec process_unauthenticated_packet(xmpp_element(), state()) -> state(). process_unauthenticated_packet(Pkt, State) -> NewPkt = set_lang(Pkt, State), try callback(handle_unauthenticated_packet, NewPkt, State) catch _:{?MODULE, undef} -> Err = xmpp:serr_not_authorized(), send(State, Err) end. -spec process_authenticated_packet(xmpp_element(), state()) -> state(). process_authenticated_packet(Pkt, State) -> Pkt1 = set_lang(Pkt, State), case set_from_to(Pkt1, State) of {ok, Pkt2} -> try callback(handle_authenticated_packet, Pkt2, State) catch _:{?MODULE, undef} -> Err = xmpp:err_service_unavailable(), send_error(State, Pkt, Err) end; {error, Err} -> send_pkt(State, Err) end. -spec process_bind(xmpp_element(), state()) -> state(). process_bind(#iq{type = set, sub_els = [_]} = Pkt, #{xmlns := ?NS_CLIENT, lang := MyLang} = State) -> try xmpp:try_subtag(Pkt, #bind{}) of #bind{resource = R} -> case callback(bind, R, State) of {ok, #{user := U, server := S, resource := NewR} = State1} when NewR /= <<"">> -> Reply = #bind{jid = jid:make(U, S, NewR)}, State2 = send_pkt(State1, xmpp:make_iq_result(Pkt, Reply)), process_stream_established(State2); {error, #stanza_error{} = Err, State1} -> send_error(State1, Pkt, Err) end; _ -> try callback(handle_unbinded_packet, Pkt, State) catch _:{?MODULE, undef} -> Err = xmpp:err_not_authorized(), send_error(State, Pkt, Err) end catch _:{xmpp_codec, Why} -> Txt = xmpp:io_format_error(Why), Lang = select_lang(MyLang, xmpp:get_lang(Pkt)), Err = xmpp:err_bad_request(Txt, Lang), send_error(State, Pkt, Err) end; process_bind(Pkt, State) -> try callback(handle_unbinded_packet, Pkt, State) catch _:{?MODULE, undef} -> Err = xmpp:err_not_authorized(), send_error(State, Pkt, Err) end. -spec process_handshake(handshake(), state()) -> state(). process_handshake(#handshake{data = Digest}, #{stream_id := StreamID, remote_server := RemoteServer} = State) -> GetPW = get_password_fun(State), AuthRes = case GetPW(<<"">>) of {false, _} -> false; {Password, _} -> sha(<>) == Digest end, case AuthRes of true -> State1 = try callback(handle_auth_success, RemoteServer, <<"handshake">>, undefined, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> State2 = send_pkt(State1, #handshake{}), process_stream_established(State2) end; false -> State1 = try callback(handle_auth_failure, RemoteServer, <<"handshake">>, <<"not authorized">>, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> send_pkt(State1, xmpp:serr_not_authorized()) end end. -spec process_stream_established(state()) -> state(). process_stream_established(#{stream_state := StateName} = State) when StateName == disconnected; StateName == established -> State; process_stream_established(State) -> State1 = State#{stream_authenticated => true, stream_state => established, stream_timeout => infinity}, try callback(handle_stream_established, State1) catch _:{?MODULE, undef} -> State1 end. -spec process_compress(compress(), state()) -> state(). process_compress(#compress{}, #{stream_compressed := Compressed, stream_authenticated := Authenticated} = State) when Compressed or not Authenticated -> send_pkt(State, #compress_failure{reason = 'setup-failed'}); process_compress(#compress{methods = HisMethods}, #{socket := Socket} = State) -> MyMethods = try callback(compress_methods, State) catch _:{?MODULE, undef} -> [] end, CommonMethods = lists_intersection(MyMethods, HisMethods), case lists:member(<<"zlib">>, CommonMethods) of true -> case xmpp_socket:compress(Socket) of {ok, ZlibSocket} -> State1 = send_pkt(State, #compressed{}), case is_disconnected(State1) of true -> State1; false -> State1#{socket => ZlibSocket, stream_id => xmpp_stream:new_id(), stream_header_sent => false, stream_restarted => true, stream_state => wait_for_stream, stream_compressed => true} end; {error, _} -> Err = #compress_failure{reason = 'setup-failed'}, send_pkt(State, Err) end; false -> send_pkt(State, #compress_failure{reason = 'unsupported-method'}) end. -spec process_starttls(state()) -> state(). process_starttls(#{stream_encrypted := true} = State) -> process_starttls_failure(already_encrypted, State); process_starttls(#{socket := Socket} = State) -> case is_starttls_available(State) of true -> TLSOpts = try callback(tls_options, State) catch _:{?MODULE, undef} -> [] end, case xmpp_socket:starttls(Socket, TLSOpts) of {ok, TLSSocket} -> State1 = send_pkt(State, #starttls_proceed{}), case is_disconnected(State1) of true -> State1; false -> State1#{socket => TLSSocket, stream_id => xmpp_stream:new_id(), stream_header_sent => false, stream_restarted => true, stream_state => wait_for_stream, stream_encrypted => true} end; {error, Reason} -> process_starttls_failure(Reason, State) end; false -> process_starttls_failure(starttls_unsupported, State) end. -spec process_starttls_failure(term(), state()) -> state(). process_starttls_failure(Why, State) -> State1 = send_pkt(State, #starttls_failure{}), case is_disconnected(State1) of true -> State1; false -> process_stream_end({tls, Why}, State1) end. -spec process_sasl_request(sasl_auth(), state()) -> state(). process_sasl_request(#sasl_auth{mechanism = Mech, text = ClientIn}, #{lserver := LServer} = State) -> State1 = State#{sasl_mech => Mech}, Mechs = get_sasl_mechanisms(State1), case lists:member(Mech, Mechs) of true when Mech == <<"EXTERNAL">> -> Res = case xmpp_stream_pkix:authenticate(State1, ClientIn) of {ok, Peer} -> {ok, [{auth_module, pkix}, {username, Peer}]}; {error, Reason, Peer} -> {error, Reason, Peer} end, process_sasl_result(Res, State1); true -> GetPW = get_password_fun(Mech, State1), CheckPW = check_password_fun(Mech, State1), CheckPWDigest = check_password_digest_fun(Mech, State1), SASLState = xmpp_sasl:server_new(LServer, GetPW, CheckPW, CheckPWDigest), Res = xmpp_sasl:server_start(SASLState, Mech, ClientIn), process_sasl_result(Res, State1#{sasl_state => SASLState}); false -> process_sasl_result({error, unsupported_mechanism, <<"">>}, State1) end. -spec process_sasl_response(sasl_response(), state()) -> state(). process_sasl_response(#sasl_response{text = ClientIn}, #{sasl_state := SASLState} = State) -> SASLResult = xmpp_sasl:server_step(SASLState, ClientIn), process_sasl_result(SASLResult, State). -spec process_sasl_result(xmpp_sasl:sasl_return(), state()) -> state(). process_sasl_result({ok, Props}, State) -> process_sasl_success(Props, <<"">>, State); process_sasl_result({ok, Props, ServerOut}, State) -> process_sasl_success(Props, ServerOut, State); process_sasl_result({continue, ServerOut, NewSASLState}, State) -> process_sasl_continue(ServerOut, NewSASLState, State); process_sasl_result({error, Reason, User}, State) -> process_sasl_failure(Reason, User, State). -spec process_sasl_success([xmpp_sasl:sasl_property()], binary(), state()) -> state(). process_sasl_success(Props, ServerOut, #{socket := Socket, sasl_mech := Mech} = State) -> User = identity(Props), AuthModule = proplists:get_value(auth_module, Props), Socket1 = xmpp_socket:reset_stream(Socket), State0 = State#{socket => Socket1}, State1 = try callback(handle_auth_success, User, Mech, AuthModule, State0) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> State2 = send_pkt(State1, #sasl_success{text = ServerOut}), case is_disconnected(State2) of true -> State2; false -> State3 = maps:remove(sasl_state, maps:remove(sasl_mech, State2)), State3#{stream_id => xmpp_stream:new_id(), stream_authenticated => true, stream_header_sent => false, stream_restarted => true, stream_state => wait_for_stream, user => User} end end. -spec process_sasl_continue(binary(), xmpp_sasl:sasl_state(), state()) -> state(). process_sasl_continue(ServerOut, NewSASLState, State) -> State1 = State#{sasl_state => NewSASLState, stream_state => wait_for_sasl_response}, send_pkt(State1, #sasl_challenge{text = ServerOut}). -spec process_sasl_failure(atom(), binary(), state()) -> state(). process_sasl_failure(Err, User, #{sasl_mech := Mech, lang := Lang} = State) -> {Reason, Text} = format_sasl_error(Mech, Err), State1 = try callback(handle_auth_failure, User, Mech, Text, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> State2 = send_pkt(State1, #sasl_failure{reason = Reason, text = xmpp:mk_text(Text, Lang)}), case is_disconnected(State2) of true -> State2; false -> State3 = maps:remove(sasl_state, maps:remove(sasl_mech, State2)), State3#{stream_state => wait_for_sasl_request} end end. -spec process_sasl_abort(state()) -> state(). process_sasl_abort(State) -> process_sasl_failure(aborted, <<"">>, State). -spec send_features(state()) -> state(). send_features(#{stream_version := {1,0}, stream_encrypted := Encrypted} = State) -> TLSRequired = is_starttls_required(State), Features = if TLSRequired and not Encrypted -> get_tls_feature(State); true -> get_sasl_feature(State) ++ get_compress_feature(State) ++ get_tls_feature(State) ++ get_bind_feature(State) ++ get_session_feature(State) ++ get_other_features(State) end, send_pkt(State, #stream_features{sub_els = Features}); send_features(State) -> %% clients and servers from stone age State. -spec get_password_fun(state()) -> fun(). get_password_fun(State) -> try callback(get_password_fun, State) catch _:{?MODULE, undef} -> fun(_) -> {false, undefined} end end. -spec get_password_fun(xmpp_sasl:mechanism(), state()) -> fun(). get_password_fun(Mech, State) -> try callback(get_password_fun, Mech, State) catch _:{?MODULE, undef} -> fun(_) -> {false, undefined} end end. -spec check_password_fun(xmpp_sasl:mechanism(), state()) -> fun(). check_password_fun(Mech, State) -> try callback(check_password_fun, Mech, State) catch _:{?MODULE, undef} -> fun(_, _, _) -> {false, undefined} end end. -spec check_password_digest_fun(xmpp_sasl:mechanism(), state()) -> fun(). check_password_digest_fun(Mech, State) -> try callback(check_password_digest_fun, Mech, State) catch _:{?MODULE, undef} -> fun(_, _, _, _, _) -> {false, undefined} end end. -spec get_sasl_mechanisms(state()) -> [xmpp_sasl:mechanism()]. get_sasl_mechanisms(#{stream_encrypted := Encrypted, xmlns := NS} = State) -> Mechs = if NS == ?NS_CLIENT -> xmpp_sasl:listmech(); true -> [] end, Mechs1 = if Encrypted -> [<<"EXTERNAL">>|Mechs]; true -> Mechs end, try callback(sasl_mechanisms, Mechs1, State) catch _:{?MODULE, undef} -> Mechs1 end. -spec get_sasl_feature(state()) -> [sasl_mechanisms()]. get_sasl_feature(#{stream_authenticated := false, stream_encrypted := Encrypted} = State) -> TLSRequired = is_starttls_required(State), if Encrypted or not TLSRequired -> Mechs = get_sasl_mechanisms(State), [#sasl_mechanisms{list = Mechs}]; true -> [] end; get_sasl_feature(_) -> []. -spec get_compress_feature(state()) -> [compression()]. get_compress_feature(#{stream_compressed := false, stream_authenticated := true} = State) -> try callback(compress_methods, State) of [] -> []; Ms -> [#compression{methods = Ms}] catch _:{?MODULE, undef} -> [] end; get_compress_feature(_) -> []. -spec get_tls_feature(state()) -> [starttls()]. get_tls_feature(#{stream_authenticated := false, stream_encrypted := false} = State) -> case is_starttls_available(State) of true -> TLSRequired = is_starttls_required(State), [#starttls{required = TLSRequired}]; false -> [] end; get_tls_feature(_) -> []. -spec get_bind_feature(state()) -> [bind()]. get_bind_feature(#{xmlns := ?NS_CLIENT, stream_authenticated := true, resource := <<"">>}) -> [#bind{}]; get_bind_feature(_) -> []. -spec get_session_feature(state()) -> [xmpp_session()]. get_session_feature(#{xmlns := ?NS_CLIENT, stream_authenticated := true, resource := <<"">>}) -> [#xmpp_session{optional = true}]; get_session_feature(_) -> []. -spec get_other_features(state()) -> [xmpp_element()]. get_other_features(#{stream_authenticated := Auth} = State) -> try if Auth -> callback(authenticated_stream_features, State); true -> callback(unauthenticated_stream_features, State) end catch _:{?MODULE, undef} -> [] end. -spec is_starttls_available(state()) -> boolean(). is_starttls_available(State) -> try callback(tls_enabled, State) catch _:{?MODULE, undef} -> true end. -spec is_starttls_required(state()) -> boolean(). is_starttls_required(State) -> try callback(tls_required, State) catch _:{?MODULE, undef} -> false end. -spec set_from_to(xmpp_element(), state()) -> {ok, xmpp_element()} | {error, stream_error()}. set_from_to(Pkt, _State) when not ?is_stanza(Pkt) -> {ok, Pkt}; set_from_to(Pkt, #{user := U, server := S, resource := R, lang := Lang, xmlns := ?NS_CLIENT}) -> JID = jid:make(U, S, R), From = case xmpp:get_from(Pkt) of undefined -> JID; F -> F end, if JID#jid.luser == From#jid.luser andalso JID#jid.lserver == From#jid.lserver andalso (JID#jid.lresource == From#jid.lresource orelse From#jid.lresource == <<"">>) -> To = case xmpp:get_to(Pkt) of undefined -> jid:make(U, S); T -> T end, {ok, xmpp:set_from_to(Pkt, JID, To)}; true -> Txt = <<"Improper 'from' attribute">>, {error, xmpp:serr_invalid_from(Txt, Lang)} end; set_from_to(Pkt, #{lang := Lang}) -> From = xmpp:get_from(Pkt), To = xmpp:get_to(Pkt), if From == undefined -> Txt = <<"Missing 'from' attribute">>, {error, xmpp:serr_improper_addressing(Txt, Lang)}; To == undefined -> Txt = <<"Missing 'to' attribute">>, {error, xmpp:serr_improper_addressing(Txt, Lang)}; true -> {ok, Pkt} end. -spec send_header(state()) -> state(). send_header(#{stream_version := Version} = State) -> send_header(State, #stream_start{version = Version}). -spec send_header(state(), stream_start()) -> state(). send_header(#{stream_id := StreamID, stream_version := MyVersion, stream_header_sent := false, lang := MyLang, xmlns := NS} = State, #stream_start{to = HisTo, from = HisFrom, lang = HisLang, version = HisVersion}) -> Lang = select_lang(MyLang, HisLang), NS_DB = if NS == ?NS_SERVER -> ?NS_SERVER_DIALBACK; true -> <<"">> end, Version = case HisVersion of undefined -> undefined; {0,_} -> HisVersion; _ -> MyVersion end, StreamStart = #stream_start{version = Version, lang = Lang, xmlns = NS, stream_xmlns = ?NS_STREAM, db_xmlns = NS_DB, id = StreamID, to = HisFrom, from = HisTo}, State1 = State#{lang => Lang, stream_version => Version, stream_header_sent => true}, case socket_send(State1, StreamStart) of ok -> State1; {error, Why} -> process_stream_end({socket, Why}, State1) end; send_header(State, _) -> State. -spec send_pkt(state(), xmpp_element() | xmlel()) -> state(). send_pkt(State, Pkt) -> Result = socket_send(State, Pkt), State1 = try callback(handle_send, Pkt, Result, State) catch _:{?MODULE, undef} -> State end, case Result of _ when is_record(Pkt, stream_error) -> process_stream_end({stream, {out, Pkt}}, State1); ok -> State1; {error, _Why} -> % Queue process_stream_end instead of calling it directly, % so we have opportunity to process incoming queued messages before % terminating session. self() ! {'$gen_event', closed}, State1 end. -spec send_error(state(), xmpp_element() | xmlel(), stanza_error()) -> state(). send_error(State, Pkt, Err) -> case xmpp:is_stanza(Pkt) of true -> case xmpp:get_type(Pkt) of result -> State; error -> State; <<"result">> -> State; <<"error">> -> State; _ -> ErrPkt = xmpp:make_error(Pkt, Err), send_pkt(State, ErrPkt) end; false -> State end. -spec send_trailer(state()) -> state(). send_trailer(State) -> socket_send(State, trailer), close_socket(State). -spec socket_send(state(), xmpp_element() | xmlel() | trailer) -> ok | {error, inet:posix()}. socket_send(#{socket := Sock, stream_state := StateName, xmlns := NS, stream_header_sent := true}, Pkt) -> case Pkt of trailer -> xmpp_socket:send_trailer(Sock); #stream_start{} when StateName /= disconnected -> xmpp_socket:send_header(Sock, xmpp:encode(Pkt)); _ when StateName /= disconnected -> xmpp_socket:send_element(Sock, xmpp:encode(Pkt, NS)); _ -> {error, closed} end; socket_send(_, _) -> {error, closed}. -spec close_socket(state()) -> state(). close_socket(#{socket := Socket} = State) -> xmpp_socket:close(Socket), State#{stream_timeout => infinity, stream_state => disconnected}. -spec select_lang(binary(), binary()) -> binary(). select_lang(Lang, <<"">>) -> Lang; select_lang(_, Lang) -> Lang. -spec set_lang(xmpp_element(), state()) -> xmpp_element(). set_lang(Pkt, #{lang := MyLang, xmlns := ?NS_CLIENT}) when ?is_stanza(Pkt) -> HisLang = xmpp:get_lang(Pkt), Lang = select_lang(MyLang, HisLang), xmpp:set_lang(Pkt, Lang); set_lang(Pkt, _) -> Pkt. -spec format_inet_error(atom()) -> string(). format_inet_error(closed) -> "connection closed"; format_inet_error(Reason) -> case inet:format_error(Reason) of "unknown POSIX error" -> atom_to_list(Reason); Txt -> Txt end. -spec format_sasl_error(xmpp_sasl:mechanism(), atom()) -> {atom(), binary()}. format_sasl_error(<<"EXTERNAL">>, Err) -> xmpp_stream_pkix:format_error(Err); format_sasl_error(Mech, Err) -> xmpp_sasl:format_error(Mech, Err). -spec format_tls_error(atom() | binary()) -> list(). format_tls_error(Reason) when is_atom(Reason) -> format_inet_error(Reason); format_tls_error(Reason) -> Reason. -spec format(io:format(), list()) -> binary(). format(Fmt, Args) -> iolist_to_binary(io_lib:format(Fmt, Args)). -spec lists_intersection(list(), list()) -> list(). lists_intersection(L1, L2) -> lists:filter( fun(E) -> lists:member(E, L2) end, L1). -spec identity([xmpp_sasl:sasl_property()]) -> binary(). identity(Props) -> case proplists:get_value(authzid, Props, <<>>) of <<>> -> proplists:get_value(username, Props, <<>>); AuthzId -> AuthzId end. -spec sha(binary()) -> binary(). sha(Data) -> xmpp_util:hex(crypto:hash(sha, Data)). %%%=================================================================== %%% Callbacks %%%=================================================================== callback(F, #{mod := Mod} = State) -> case erlang:function_exported(Mod, F, 1) of true -> Mod:F(State); false -> erlang:error({?MODULE, undef}) end. callback(F, Arg1, #{mod := Mod} = State) -> case erlang:function_exported(Mod, F, 2) of true -> Mod:F(Arg1, State); false -> erlang:error({?MODULE, undef}) end. callback(code_change, OldVsn, #{mod := Mod} = State, Extra) -> %% code_change/3 callback is a special snowflake case erlang:function_exported(Mod, code_change, 3) of true -> Mod:code_change(OldVsn, State, Extra); false -> {ok, State} end; callback(F, Arg1, Arg2, #{mod := Mod} = State) -> case erlang:function_exported(Mod, F, 3) of true -> Mod:F(Arg1, Arg2, State); false -> erlang:error({?MODULE, undef}) end. callback(F, Arg1, Arg2, Arg3, #{mod := Mod} = State) -> case erlang:function_exported(Mod, F, 4) of true -> Mod:F(Arg1, Arg2, Arg3, State); false -> erlang:error({?MODULE, undef}) end. xmpp-1.4.4/src/xmpp_uri.erl0000644000232200023220000000371613610066730016221 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% XMPP URI processing library (see RFC5122) %%% @end %%% Created : 27 Nov 2017 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_uri). %% API -export([start/0, is_valid/1, check/1]). %%%=================================================================== %%% API %%%=================================================================== -spec start() -> ok | {error, unable_to_load_nif}. start() -> load_nif(p1_nif_utils:get_so_path(?MODULE, [xmpp_uri], "xmpp_uri")). load_nif(SOPath) -> case catch erlang:load_nif(SOPath, 0) of ok -> ok; {error, {reload, _}} -> ok; Err -> error_logger:warning_msg("unable to load xmpp_uri NIF: ~p~n", [Err]), {error, unable_to_load_nif} end. -spec is_valid(binary()) -> boolean(). is_valid(_) -> erlang:nif_error(nif_not_loaded). -spec check(binary()) -> binary(). check(<<>>) -> <<>>; check(S) -> case is_valid(S) of true -> S; false -> erlang:error({bad_uri, S}) end. %%%=================================================================== %%% Internal functions %%%=================================================================== xmpp-1.4.4/src/xep0357.erl0000644000232200023220000001757213610066730015476 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0357). -compile(export_all). do_decode(<<"notification">>, <<"urn:xmpp:push:0">>, El, Opts) -> decode_push_notification(<<"urn:xmpp:push:0">>, Opts, El); do_decode(<<"disable">>, <<"urn:xmpp:push:0">>, El, Opts) -> decode_push_disable(<<"urn:xmpp:push:0">>, Opts, El); do_decode(<<"enable">>, <<"urn:xmpp:push:0">>, El, Opts) -> decode_push_enable(<<"urn:xmpp:push:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"notification">>, <<"urn:xmpp:push:0">>}, {<<"disable">>, <<"urn:xmpp:push:0">>}, {<<"enable">>, <<"urn:xmpp:push:0">>}]. do_encode({push_enable, _, _, _} = Enable, TopXMLNS) -> encode_push_enable(Enable, TopXMLNS); do_encode({push_disable, _, _} = Disable, TopXMLNS) -> encode_push_disable(Disable, TopXMLNS); do_encode({push_notification, _} = Notification, TopXMLNS) -> encode_push_notification(Notification, TopXMLNS). do_get_name({push_disable, _, _}) -> <<"disable">>; do_get_name({push_enable, _, _, _}) -> <<"enable">>; do_get_name({push_notification, _}) -> <<"notification">>. do_get_ns({push_disable, _, _}) -> <<"urn:xmpp:push:0">>; do_get_ns({push_enable, _, _, _}) -> <<"urn:xmpp:push:0">>; do_get_ns({push_notification, _}) -> <<"urn:xmpp:push:0">>. pp(push_enable, 3) -> [jid, node, xdata]; pp(push_disable, 2) -> [jid, node]; pp(push_notification, 1) -> [xdata]; pp(_, _) -> no. records() -> [{push_enable, 3}, {push_disable, 2}, {push_notification, 1}]. decode_push_notification(__TopXMLNS, __Opts, {xmlel, <<"notification">>, _attrs, _els}) -> Xdata = decode_push_notification_els(__TopXMLNS, __Opts, _els, undefined), {push_notification, Xdata}. decode_push_notification_els(__TopXMLNS, __Opts, [], Xdata) -> Xdata; decode_push_notification_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_push_notification_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_push_notification_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_push_notification_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_push_notification_els(__TopXMLNS, __Opts, _els, Xdata). encode_push_notification({push_notification, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:push:0">>, [], __TopXMLNS), _els = lists:reverse('encode_push_notification_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"notification">>, _attrs, _els}. 'encode_push_notification_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_push_notification_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. decode_push_disable(__TopXMLNS, __Opts, {xmlel, <<"disable">>, _attrs, _els}) -> {Jid, Node} = decode_push_disable_attrs(__TopXMLNS, _attrs, undefined, undefined), {push_disable, Jid, Node}. decode_push_disable_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Node) -> decode_push_disable_attrs(__TopXMLNS, _attrs, _val, Node); decode_push_disable_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Jid, _Node) -> decode_push_disable_attrs(__TopXMLNS, _attrs, Jid, _val); decode_push_disable_attrs(__TopXMLNS, [_ | _attrs], Jid, Node) -> decode_push_disable_attrs(__TopXMLNS, _attrs, Jid, Node); decode_push_disable_attrs(__TopXMLNS, [], Jid, Node) -> {decode_push_disable_attr_jid(__TopXMLNS, Jid), decode_push_disable_attr_node(__TopXMLNS, Node)}. encode_push_disable({push_disable, Jid, Node}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:push:0">>, [], __TopXMLNS), _els = [], _attrs = encode_push_disable_attr_node(Node, encode_push_disable_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"disable">>, _attrs, _els}. decode_push_disable_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"disable">>, __TopXMLNS}}); decode_push_disable_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"disable">>, __TopXMLNS}}); _res -> _res end. encode_push_disable_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_push_disable_attr_node(__TopXMLNS, undefined) -> <<>>; decode_push_disable_attr_node(__TopXMLNS, _val) -> _val. encode_push_disable_attr_node(<<>>, _acc) -> _acc; encode_push_disable_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_push_enable(__TopXMLNS, __Opts, {xmlel, <<"enable">>, _attrs, _els}) -> Xdata = decode_push_enable_els(__TopXMLNS, __Opts, _els, undefined), {Jid, Node} = decode_push_enable_attrs(__TopXMLNS, _attrs, undefined, undefined), {push_enable, Jid, Node, Xdata}. decode_push_enable_els(__TopXMLNS, __Opts, [], Xdata) -> Xdata; decode_push_enable_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_push_enable_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_push_enable_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_push_enable_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_push_enable_els(__TopXMLNS, __Opts, _els, Xdata). decode_push_enable_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Node) -> decode_push_enable_attrs(__TopXMLNS, _attrs, _val, Node); decode_push_enable_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Jid, _Node) -> decode_push_enable_attrs(__TopXMLNS, _attrs, Jid, _val); decode_push_enable_attrs(__TopXMLNS, [_ | _attrs], Jid, Node) -> decode_push_enable_attrs(__TopXMLNS, _attrs, Jid, Node); decode_push_enable_attrs(__TopXMLNS, [], Jid, Node) -> {decode_push_enable_attr_jid(__TopXMLNS, Jid), decode_push_enable_attr_node(__TopXMLNS, Node)}. encode_push_enable({push_enable, Jid, Node, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:push:0">>, [], __TopXMLNS), _els = lists:reverse('encode_push_enable_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = encode_push_enable_attr_node(Node, encode_push_enable_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"enable">>, _attrs, _els}. 'encode_push_enable_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_push_enable_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. decode_push_enable_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"enable">>, __TopXMLNS}}); decode_push_enable_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"enable">>, __TopXMLNS}}); _res -> _res end. encode_push_enable_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_push_enable_attr_node(__TopXMLNS, undefined) -> <<>>; decode_push_enable_attr_node(__TopXMLNS, _val) -> _val. encode_push_enable_attr_node(<<>>, _acc) -> _acc; encode_push_enable_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. xmpp-1.4.4/src/xep0049.erl0000644000232200023220000000327013610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0049). -compile(export_all). do_decode(<<"query">>, <<"jabber:iq:private">>, El, Opts) -> decode_private(<<"jabber:iq:private">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"jabber:iq:private">>}]. do_encode({private, _} = Query, TopXMLNS) -> encode_private(Query, TopXMLNS). do_get_name({private, _}) -> <<"query">>. do_get_ns({private, _}) -> <<"jabber:iq:private">>. get_els({private, _sub_els}) -> _sub_els. set_els({private, _}, _sub_els) -> {private, _sub_els}. pp(private, 1) -> [sub_els]; pp(_, _) -> no. records() -> [{private, 1}]. decode_private(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> __Els = decode_private_els(__TopXMLNS, __Opts, _els, []), {private, __Els}. decode_private_els(__TopXMLNS, __Opts, [], __Els) -> lists:reverse(__Els); decode_private_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], __Els) -> decode_private_els(__TopXMLNS, __Opts, _els, [_el | __Els]); decode_private_els(__TopXMLNS, __Opts, [_ | _els], __Els) -> decode_private_els(__TopXMLNS, __Opts, _els, __Els). encode_private({private, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:private">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. xmpp-1.4.4/src/xep0115.erl0000644000232200023220000000731513610066730015460 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0115). -compile(export_all). do_decode(<<"c">>, <<"http://jabber.org/protocol/caps">>, El, Opts) -> decode_caps(<<"http://jabber.org/protocol/caps">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"c">>, <<"http://jabber.org/protocol/caps">>}]. do_encode({caps, _, _, _, _} = C, TopXMLNS) -> encode_caps(C, TopXMLNS). do_get_name({caps, _, _, _, _}) -> <<"c">>. do_get_ns({caps, _, _, _, _}) -> <<"http://jabber.org/protocol/caps">>. pp(caps, 4) -> [node, version, hash, exts]; pp(_, _) -> no. records() -> [{caps, 4}]. join([], _Sep) -> <<>>; join([H | T], Sep) -> <> || X <- T >>/binary>>. decode_caps(__TopXMLNS, __Opts, {xmlel, <<"c">>, _attrs, _els}) -> {Hash, Node, Exts, Version} = decode_caps_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {caps, Node, Version, Hash, Exts}. decode_caps_attrs(__TopXMLNS, [{<<"hash">>, _val} | _attrs], _Hash, Node, Exts, Version) -> decode_caps_attrs(__TopXMLNS, _attrs, _val, Node, Exts, Version); decode_caps_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Hash, _Node, Exts, Version) -> decode_caps_attrs(__TopXMLNS, _attrs, Hash, _val, Exts, Version); decode_caps_attrs(__TopXMLNS, [{<<"ext">>, _val} | _attrs], Hash, Node, _Exts, Version) -> decode_caps_attrs(__TopXMLNS, _attrs, Hash, Node, _val, Version); decode_caps_attrs(__TopXMLNS, [{<<"ver">>, _val} | _attrs], Hash, Node, Exts, _Version) -> decode_caps_attrs(__TopXMLNS, _attrs, Hash, Node, Exts, _val); decode_caps_attrs(__TopXMLNS, [_ | _attrs], Hash, Node, Exts, Version) -> decode_caps_attrs(__TopXMLNS, _attrs, Hash, Node, Exts, Version); decode_caps_attrs(__TopXMLNS, [], Hash, Node, Exts, Version) -> {decode_caps_attr_hash(__TopXMLNS, Hash), decode_caps_attr_node(__TopXMLNS, Node), decode_caps_attr_ext(__TopXMLNS, Exts), decode_caps_attr_ver(__TopXMLNS, Version)}. encode_caps({caps, Node, Version, Hash, Exts}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/caps">>, [], __TopXMLNS), _els = [], _attrs = encode_caps_attr_ver(Version, encode_caps_attr_ext(Exts, encode_caps_attr_node(Node, encode_caps_attr_hash(Hash, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"c">>, _attrs, _els}. decode_caps_attr_hash(__TopXMLNS, undefined) -> <<>>; decode_caps_attr_hash(__TopXMLNS, _val) -> _val. encode_caps_attr_hash(<<>>, _acc) -> _acc; encode_caps_attr_hash(_val, _acc) -> [{<<"hash">>, _val} | _acc]. decode_caps_attr_node(__TopXMLNS, undefined) -> <<>>; decode_caps_attr_node(__TopXMLNS, _val) -> _val. encode_caps_attr_node(<<>>, _acc) -> _acc; encode_caps_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_caps_attr_ext(__TopXMLNS, undefined) -> []; decode_caps_attr_ext(__TopXMLNS, _val) -> case catch re:split(_val, "\\h+") of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"ext">>, <<"c">>, __TopXMLNS}}); _res -> _res end. encode_caps_attr_ext([], _acc) -> _acc; encode_caps_attr_ext(_val, _acc) -> [{<<"ext">>, join(_val, 32)} | _acc]. decode_caps_attr_ver(__TopXMLNS, undefined) -> <<>>; decode_caps_attr_ver(__TopXMLNS, _val) -> _val. encode_caps_attr_ver(<<>>, _acc) -> _acc; encode_caps_attr_ver(_val, _acc) -> [{<<"ver">>, _val} | _acc]. xmpp-1.4.4/src/xmpp_tr.erl0000644000232200023220000000234213610066730016041 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% Fallback language translation module %%% @end %%% Created : 17 Mar 2017 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_tr). %% API -export([tr/2]). %%%=================================================================== %%% API %%%=================================================================== -spec tr(binary(), binary()) -> binary(). tr(_Lang, Text) -> Text. xmpp-1.4.4/src/xep0004.erl0000644000232200023220000006601513610066730015457 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0004). -compile(export_all). do_decode(<<"x">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata(<<"jabber:x:data">>, Opts, El); do_decode(<<"item">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_item(<<"jabber:x:data">>, Opts, El); do_decode(<<"reported">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_reported(<<"jabber:x:data">>, Opts, El); do_decode(<<"title">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_title(<<"jabber:x:data">>, Opts, El); do_decode(<<"instructions">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_instructions(<<"jabber:x:data">>, Opts, El); do_decode(<<"field">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_field(<<"jabber:x:data">>, Opts, El); do_decode(<<"option">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_field_option(<<"jabber:x:data">>, Opts, El); do_decode(<<"value">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_field_value(<<"jabber:x:data">>, Opts, El); do_decode(<<"desc">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_field_desc(<<"jabber:x:data">>, Opts, El); do_decode(<<"required">>, <<"jabber:x:data">>, El, Opts) -> decode_xdata_field_required(<<"jabber:x:data">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"x">>, <<"jabber:x:data">>}, {<<"item">>, <<"jabber:x:data">>}, {<<"reported">>, <<"jabber:x:data">>}, {<<"title">>, <<"jabber:x:data">>}, {<<"instructions">>, <<"jabber:x:data">>}, {<<"field">>, <<"jabber:x:data">>}, {<<"option">>, <<"jabber:x:data">>}, {<<"value">>, <<"jabber:x:data">>}, {<<"desc">>, <<"jabber:x:data">>}, {<<"required">>, <<"jabber:x:data">>}]. do_encode({xdata_option, _, _} = Option, TopXMLNS) -> encode_xdata_field_option(Option, TopXMLNS); do_encode({xdata_field, _, _, _, _, _, _, _, _} = Field, TopXMLNS) -> encode_xdata_field(Field, TopXMLNS); do_encode({xdata, _, _, _, _, _, _} = X, TopXMLNS) -> encode_xdata(X, TopXMLNS). do_get_name({xdata, _, _, _, _, _, _}) -> <<"x">>; do_get_name({xdata_field, _, _, _, _, _, _, _, _}) -> <<"field">>; do_get_name({xdata_option, _, _}) -> <<"option">>. do_get_ns({xdata, _, _, _, _, _, _}) -> <<"jabber:x:data">>; do_get_ns({xdata_field, _, _, _, _, _, _, _, _}) -> <<"jabber:x:data">>; do_get_ns({xdata_option, _, _}) -> <<"jabber:x:data">>. get_els({xdata_field, _label, _type, _var, _required, _desc, _values, _options, _sub_els}) -> _sub_els. set_els({xdata_field, _label, _type, _var, _required, _desc, _values, _options, _}, _sub_els) -> {xdata_field, _label, _type, _var, _required, _desc, _values, _options, _sub_els}. pp(xdata_option, 2) -> [label, value]; pp(xdata_field, 8) -> [label, type, var, required, desc, values, options, sub_els]; pp(xdata, 6) -> [type, instructions, title, reported, items, fields]; pp(_, _) -> no. records() -> [{xdata_option, 2}, {xdata_field, 8}, {xdata, 6}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). decode_xdata(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> {Fields, Items, Instructions, Reported, Title} = decode_xdata_els(__TopXMLNS, __Opts, _els, [], [], [], undefined, undefined), Type = decode_xdata_attrs(__TopXMLNS, _attrs, undefined), {xdata, Type, Instructions, Title, Reported, Items, Fields}. decode_xdata_els(__TopXMLNS, __Opts, [], Fields, Items, Instructions, Reported, Title) -> {lists:reverse(Fields), lists:reverse(Items), lists:reverse(Instructions), Reported, Title}; decode_xdata_els(__TopXMLNS, __Opts, [{xmlel, <<"instructions">>, _attrs, _} = _el | _els], Fields, Items, Instructions, Reported, Title) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, [decode_xdata_instructions(<<"jabber:x:data">>, __Opts, _el) | Instructions], Reported, Title); _ -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, Reported, Title) end; decode_xdata_els(__TopXMLNS, __Opts, [{xmlel, <<"title">>, _attrs, _} = _el | _els], Fields, Items, Instructions, Reported, Title) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, Reported, decode_xdata_title(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, Reported, Title) end; decode_xdata_els(__TopXMLNS, __Opts, [{xmlel, <<"reported">>, _attrs, _} = _el | _els], Fields, Items, Instructions, Reported, Title) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, decode_xdata_reported(<<"jabber:x:data">>, __Opts, _el), Title); _ -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, Reported, Title) end; decode_xdata_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Fields, Items, Instructions, Reported, Title) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, [decode_xdata_item(<<"jabber:x:data">>, __Opts, _el) | Items], Instructions, Reported, Title); _ -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, Reported, Title) end; decode_xdata_els(__TopXMLNS, __Opts, [{xmlel, <<"field">>, _attrs, _} = _el | _els], Fields, Items, Instructions, Reported, Title) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_els(__TopXMLNS, __Opts, _els, [decode_xdata_field(<<"jabber:x:data">>, __Opts, _el) | Fields], Items, Instructions, Reported, Title); _ -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, Reported, Title) end; decode_xdata_els(__TopXMLNS, __Opts, [_ | _els], Fields, Items, Instructions, Reported, Title) -> decode_xdata_els(__TopXMLNS, __Opts, _els, Fields, Items, Instructions, Reported, Title). decode_xdata_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], _Type) -> decode_xdata_attrs(__TopXMLNS, _attrs, _val); decode_xdata_attrs(__TopXMLNS, [_ | _attrs], Type) -> decode_xdata_attrs(__TopXMLNS, _attrs, Type); decode_xdata_attrs(__TopXMLNS, [], Type) -> decode_xdata_attr_type(__TopXMLNS, Type). encode_xdata({xdata, Type, Instructions, Title, Reported, Items, Fields}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = lists:reverse('encode_xdata_$fields'(Fields, __NewTopXMLNS, 'encode_xdata_$items'(Items, __NewTopXMLNS, 'encode_xdata_$instructions'(Instructions, __NewTopXMLNS, 'encode_xdata_$reported'(Reported, __NewTopXMLNS, 'encode_xdata_$title'(Title, __NewTopXMLNS, [])))))), _attrs = encode_xdata_attr_type(Type, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"x">>, _attrs, _els}. 'encode_xdata_$fields'([], __TopXMLNS, _acc) -> _acc; 'encode_xdata_$fields'([Fields | _els], __TopXMLNS, _acc) -> 'encode_xdata_$fields'(_els, __TopXMLNS, [encode_xdata_field(Fields, __TopXMLNS) | _acc]). 'encode_xdata_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_xdata_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_xdata_$items'(_els, __TopXMLNS, [encode_xdata_item(Items, __TopXMLNS) | _acc]). 'encode_xdata_$instructions'([], __TopXMLNS, _acc) -> _acc; 'encode_xdata_$instructions'([Instructions | _els], __TopXMLNS, _acc) -> 'encode_xdata_$instructions'(_els, __TopXMLNS, [encode_xdata_instructions(Instructions, __TopXMLNS) | _acc]). 'encode_xdata_$reported'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_xdata_$reported'(Reported, __TopXMLNS, _acc) -> [encode_xdata_reported(Reported, __TopXMLNS) | _acc]. 'encode_xdata_$title'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_xdata_$title'(Title, __TopXMLNS, _acc) -> [encode_xdata_title(Title, __TopXMLNS) | _acc]. decode_xdata_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"x">>, __TopXMLNS}}); decode_xdata_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [cancel, form, result, submit]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"x">>, __TopXMLNS}}); _res -> _res end. encode_xdata_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_xdata_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> Fields = decode_xdata_item_els(__TopXMLNS, __Opts, _els, []), Fields. decode_xdata_item_els(__TopXMLNS, __Opts, [], Fields) -> lists:reverse(Fields); decode_xdata_item_els(__TopXMLNS, __Opts, [{xmlel, <<"field">>, _attrs, _} = _el | _els], Fields) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_item_els(__TopXMLNS, __Opts, _els, [decode_xdata_field(<<"jabber:x:data">>, __Opts, _el) | Fields]); _ -> decode_xdata_item_els(__TopXMLNS, __Opts, _els, Fields) end; decode_xdata_item_els(__TopXMLNS, __Opts, [_ | _els], Fields) -> decode_xdata_item_els(__TopXMLNS, __Opts, _els, Fields). encode_xdata_item(Fields, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = lists:reverse('encode_xdata_item_$fields'(Fields, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"item">>, _attrs, _els}. 'encode_xdata_item_$fields'([], __TopXMLNS, _acc) -> _acc; 'encode_xdata_item_$fields'([Fields | _els], __TopXMLNS, _acc) -> 'encode_xdata_item_$fields'(_els, __TopXMLNS, [encode_xdata_field(Fields, __TopXMLNS) | _acc]). decode_xdata_reported(__TopXMLNS, __Opts, {xmlel, <<"reported">>, _attrs, _els}) -> Fields = decode_xdata_reported_els(__TopXMLNS, __Opts, _els, []), Fields. decode_xdata_reported_els(__TopXMLNS, __Opts, [], Fields) -> lists:reverse(Fields); decode_xdata_reported_els(__TopXMLNS, __Opts, [{xmlel, <<"field">>, _attrs, _} = _el | _els], Fields) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_reported_els(__TopXMLNS, __Opts, _els, [decode_xdata_field(<<"jabber:x:data">>, __Opts, _el) | Fields]); _ -> decode_xdata_reported_els(__TopXMLNS, __Opts, _els, Fields) end; decode_xdata_reported_els(__TopXMLNS, __Opts, [_ | _els], Fields) -> decode_xdata_reported_els(__TopXMLNS, __Opts, _els, Fields). encode_xdata_reported(Fields, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = lists:reverse('encode_xdata_reported_$fields'(Fields, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"reported">>, _attrs, _els}. 'encode_xdata_reported_$fields'([], __TopXMLNS, _acc) -> _acc; 'encode_xdata_reported_$fields'([Fields | _els], __TopXMLNS, _acc) -> 'encode_xdata_reported_$fields'(_els, __TopXMLNS, [encode_xdata_field(Fields, __TopXMLNS) | _acc]). decode_xdata_title(__TopXMLNS, __Opts, {xmlel, <<"title">>, _attrs, _els}) -> Cdata = decode_xdata_title_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_xdata_title_els(__TopXMLNS, __Opts, [], Cdata) -> decode_xdata_title_cdata(__TopXMLNS, Cdata); decode_xdata_title_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_xdata_title_els(__TopXMLNS, __Opts, _els, <>); decode_xdata_title_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_xdata_title_els(__TopXMLNS, __Opts, _els, Cdata). encode_xdata_title(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = encode_xdata_title_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"title">>, _attrs, _els}. decode_xdata_title_cdata(__TopXMLNS, <<>>) -> <<>>; decode_xdata_title_cdata(__TopXMLNS, _val) -> _val. encode_xdata_title_cdata(<<>>, _acc) -> _acc; encode_xdata_title_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_xdata_instructions(__TopXMLNS, __Opts, {xmlel, <<"instructions">>, _attrs, _els}) -> Cdata = decode_xdata_instructions_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_xdata_instructions_els(__TopXMLNS, __Opts, [], Cdata) -> decode_xdata_instructions_cdata(__TopXMLNS, Cdata); decode_xdata_instructions_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_xdata_instructions_els(__TopXMLNS, __Opts, _els, <>); decode_xdata_instructions_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_xdata_instructions_els(__TopXMLNS, __Opts, _els, Cdata). encode_xdata_instructions(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = encode_xdata_instructions_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"instructions">>, _attrs, _els}. decode_xdata_instructions_cdata(__TopXMLNS, <<>>) -> <<>>; decode_xdata_instructions_cdata(__TopXMLNS, _val) -> _val. encode_xdata_instructions_cdata(<<>>, _acc) -> _acc; encode_xdata_instructions_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_xdata_field(__TopXMLNS, __Opts, {xmlel, <<"field">>, _attrs, _els}) -> {Options, Values, Desc, Required, __Els} = decode_xdata_field_els(__TopXMLNS, __Opts, _els, [], [], <<>>, false, []), {Label, Type, Var} = decode_xdata_field_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {xdata_field, Label, Type, Var, Required, Desc, Values, Options, __Els}. decode_xdata_field_els(__TopXMLNS, __Opts, [], Options, Values, Desc, Required, __Els) -> {lists:reverse(Options), lists:reverse(Values), Desc, Required, lists:reverse(__Els)}; decode_xdata_field_els(__TopXMLNS, __Opts, [{xmlel, <<"required">>, _attrs, _} = _el | _els], Options, Values, Desc, Required, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, decode_xdata_field_required(<<"jabber:x:data">>, __Opts, _el), __Els); _ -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, [_el | __Els]) end; decode_xdata_field_els(__TopXMLNS, __Opts, [{xmlel, <<"desc">>, _attrs, _} = _el | _els], Options, Values, Desc, Required, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, decode_xdata_field_desc(<<"jabber:x:data">>, __Opts, _el), Required, __Els); _ -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, [_el | __Els]) end; decode_xdata_field_els(__TopXMLNS, __Opts, [{xmlel, <<"value">>, _attrs, _} = _el | _els], Options, Values, Desc, Required, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, [decode_xdata_field_value(<<"jabber:x:data">>, __Opts, _el) | Values], Desc, Required, __Els); _ -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, [_el | __Els]) end; decode_xdata_field_els(__TopXMLNS, __Opts, [{xmlel, <<"option">>, _attrs, _} = _el | _els], Options, Values, Desc, Required, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, [decode_xdata_field_option(<<"jabber:x:data">>, __Opts, _el) | Options], Values, Desc, Required, __Els); _ -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, [_el | __Els]) end; decode_xdata_field_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Options, Values, Desc, Required, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, [_el | __Els]); Mod -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_xdata_field_els(__TopXMLNS, __Opts, [_ | _els], Options, Values, Desc, Required, __Els) -> decode_xdata_field_els(__TopXMLNS, __Opts, _els, Options, Values, Desc, Required, __Els). decode_xdata_field_attrs(__TopXMLNS, [{<<"label">>, _val} | _attrs], _Label, Type, Var) -> decode_xdata_field_attrs(__TopXMLNS, _attrs, _val, Type, Var); decode_xdata_field_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Label, _Type, Var) -> decode_xdata_field_attrs(__TopXMLNS, _attrs, Label, _val, Var); decode_xdata_field_attrs(__TopXMLNS, [{<<"var">>, _val} | _attrs], Label, Type, _Var) -> decode_xdata_field_attrs(__TopXMLNS, _attrs, Label, Type, _val); decode_xdata_field_attrs(__TopXMLNS, [_ | _attrs], Label, Type, Var) -> decode_xdata_field_attrs(__TopXMLNS, _attrs, Label, Type, Var); decode_xdata_field_attrs(__TopXMLNS, [], Label, Type, Var) -> {decode_xdata_field_attr_label(__TopXMLNS, Label), decode_xdata_field_attr_type(__TopXMLNS, Type), decode_xdata_field_attr_var(__TopXMLNS, Var)}. encode_xdata_field({xdata_field, Label, Type, Var, Required, Desc, Values, Options, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_xdata_field_$options'(Options, __NewTopXMLNS, 'encode_xdata_field_$values'(Values, __NewTopXMLNS, 'encode_xdata_field_$desc'(Desc, __NewTopXMLNS, 'encode_xdata_field_$required'(Required, __NewTopXMLNS, []))))), _attrs = encode_xdata_field_attr_var(Var, encode_xdata_field_attr_type(Type, encode_xdata_field_attr_label(Label, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"field">>, _attrs, _els}. 'encode_xdata_field_$options'([], __TopXMLNS, _acc) -> _acc; 'encode_xdata_field_$options'([Options | _els], __TopXMLNS, _acc) -> 'encode_xdata_field_$options'(_els, __TopXMLNS, [encode_xdata_field_option(Options, __TopXMLNS) | _acc]). 'encode_xdata_field_$values'([], __TopXMLNS, _acc) -> _acc; 'encode_xdata_field_$values'([Values | _els], __TopXMLNS, _acc) -> 'encode_xdata_field_$values'(_els, __TopXMLNS, [encode_xdata_field_value(Values, __TopXMLNS) | _acc]). 'encode_xdata_field_$desc'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_xdata_field_$desc'(Desc, __TopXMLNS, _acc) -> [encode_xdata_field_desc(Desc, __TopXMLNS) | _acc]. 'encode_xdata_field_$required'(false, __TopXMLNS, _acc) -> _acc; 'encode_xdata_field_$required'(Required, __TopXMLNS, _acc) -> [encode_xdata_field_required(Required, __TopXMLNS) | _acc]. decode_xdata_field_attr_label(__TopXMLNS, undefined) -> <<>>; decode_xdata_field_attr_label(__TopXMLNS, _val) -> _val. encode_xdata_field_attr_label(<<>>, _acc) -> _acc; encode_xdata_field_attr_label(_val, _acc) -> [{<<"label">>, _val} | _acc]. decode_xdata_field_attr_type(__TopXMLNS, undefined) -> undefined; decode_xdata_field_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [boolean, fixed, hidden, 'jid-multi', 'jid-single', 'list-multi', 'list-single', 'text-multi', 'text-private', 'text-single']) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"field">>, __TopXMLNS}}); _res -> _res end. encode_xdata_field_attr_type(undefined, _acc) -> _acc; encode_xdata_field_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_xdata_field_attr_var(__TopXMLNS, undefined) -> <<>>; decode_xdata_field_attr_var(__TopXMLNS, _val) -> _val. encode_xdata_field_attr_var(<<>>, _acc) -> _acc; encode_xdata_field_attr_var(_val, _acc) -> [{<<"var">>, _val} | _acc]. decode_xdata_field_option(__TopXMLNS, __Opts, {xmlel, <<"option">>, _attrs, _els}) -> Value = decode_xdata_field_option_els(__TopXMLNS, __Opts, _els, error), Label = decode_xdata_field_option_attrs(__TopXMLNS, _attrs, undefined), {xdata_option, Label, Value}. decode_xdata_field_option_els(__TopXMLNS, __Opts, [], Value) -> case Value of error -> erlang:error({xmpp_codec, {missing_tag, <<"value">>, __TopXMLNS}}); {value, Value1} -> Value1 end; decode_xdata_field_option_els(__TopXMLNS, __Opts, [{xmlel, <<"value">>, _attrs, _} = _el | _els], Value) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_xdata_field_option_els(__TopXMLNS, __Opts, _els, {value, decode_xdata_field_value(<<"jabber:x:data">>, __Opts, _el)}); _ -> decode_xdata_field_option_els(__TopXMLNS, __Opts, _els, Value) end; decode_xdata_field_option_els(__TopXMLNS, __Opts, [_ | _els], Value) -> decode_xdata_field_option_els(__TopXMLNS, __Opts, _els, Value). decode_xdata_field_option_attrs(__TopXMLNS, [{<<"label">>, _val} | _attrs], _Label) -> decode_xdata_field_option_attrs(__TopXMLNS, _attrs, _val); decode_xdata_field_option_attrs(__TopXMLNS, [_ | _attrs], Label) -> decode_xdata_field_option_attrs(__TopXMLNS, _attrs, Label); decode_xdata_field_option_attrs(__TopXMLNS, [], Label) -> decode_xdata_field_option_attr_label(__TopXMLNS, Label). encode_xdata_field_option({xdata_option, Label, Value}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = lists:reverse('encode_xdata_field_option_$value'(Value, __NewTopXMLNS, [])), _attrs = encode_xdata_field_option_attr_label(Label, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"option">>, _attrs, _els}. 'encode_xdata_field_option_$value'(Value, __TopXMLNS, _acc) -> [encode_xdata_field_value(Value, __TopXMLNS) | _acc]. decode_xdata_field_option_attr_label(__TopXMLNS, undefined) -> <<>>; decode_xdata_field_option_attr_label(__TopXMLNS, _val) -> _val. encode_xdata_field_option_attr_label(<<>>, _acc) -> _acc; encode_xdata_field_option_attr_label(_val, _acc) -> [{<<"label">>, _val} | _acc]. decode_xdata_field_value(__TopXMLNS, __Opts, {xmlel, <<"value">>, _attrs, _els}) -> Cdata = decode_xdata_field_value_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_xdata_field_value_els(__TopXMLNS, __Opts, [], Cdata) -> decode_xdata_field_value_cdata(__TopXMLNS, Cdata); decode_xdata_field_value_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_xdata_field_value_els(__TopXMLNS, __Opts, _els, <>); decode_xdata_field_value_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_xdata_field_value_els(__TopXMLNS, __Opts, _els, Cdata). encode_xdata_field_value(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = encode_xdata_field_value_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"value">>, _attrs, _els}. decode_xdata_field_value_cdata(__TopXMLNS, <<>>) -> <<>>; decode_xdata_field_value_cdata(__TopXMLNS, _val) -> _val. encode_xdata_field_value_cdata(<<>>, _acc) -> _acc; encode_xdata_field_value_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_xdata_field_desc(__TopXMLNS, __Opts, {xmlel, <<"desc">>, _attrs, _els}) -> Cdata = decode_xdata_field_desc_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_xdata_field_desc_els(__TopXMLNS, __Opts, [], Cdata) -> decode_xdata_field_desc_cdata(__TopXMLNS, Cdata); decode_xdata_field_desc_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_xdata_field_desc_els(__TopXMLNS, __Opts, _els, <>); decode_xdata_field_desc_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_xdata_field_desc_els(__TopXMLNS, __Opts, _els, Cdata). encode_xdata_field_desc(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = encode_xdata_field_desc_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"desc">>, _attrs, _els}. decode_xdata_field_desc_cdata(__TopXMLNS, <<>>) -> <<>>; decode_xdata_field_desc_cdata(__TopXMLNS, _val) -> _val. encode_xdata_field_desc_cdata(<<>>, _acc) -> _acc; encode_xdata_field_desc_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_xdata_field_required(__TopXMLNS, __Opts, {xmlel, <<"required">>, _attrs, _els}) -> true. encode_xdata_field_required(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:data">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"required">>, _attrs, _els}. xmpp-1.4.4/src/xep0334.erl0000644000232200023220000001250713610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0334). -compile(export_all). do_decode(<<"no-permanent-storage">>, <<"urn:xmpp:hints">>, El, Opts) -> decode_hint_no_permanent_storage(<<"urn:xmpp:hints">>, Opts, El); do_decode(<<"no-permanent-store">>, <<"urn:xmpp:hints">>, El, Opts) -> decode_hint_no_permanent_store(<<"urn:xmpp:hints">>, Opts, El); do_decode(<<"store">>, <<"urn:xmpp:hints">>, El, Opts) -> decode_hint_store(<<"urn:xmpp:hints">>, Opts, El); do_decode(<<"no-storage">>, <<"urn:xmpp:hints">>, El, Opts) -> decode_hint_no_storage(<<"urn:xmpp:hints">>, Opts, El); do_decode(<<"no-store">>, <<"urn:xmpp:hints">>, El, Opts) -> decode_hint_no_store(<<"urn:xmpp:hints">>, Opts, El); do_decode(<<"no-copy">>, <<"urn:xmpp:hints">>, El, Opts) -> decode_hint_no_copy(<<"urn:xmpp:hints">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"no-permanent-storage">>, <<"urn:xmpp:hints">>}, {<<"no-permanent-store">>, <<"urn:xmpp:hints">>}, {<<"store">>, <<"urn:xmpp:hints">>}, {<<"no-storage">>, <<"urn:xmpp:hints">>}, {<<"no-store">>, <<"urn:xmpp:hints">>}, {<<"no-copy">>, <<"urn:xmpp:hints">>}]. do_encode({hint, 'no-copy'} = No_copy, TopXMLNS) -> encode_hint_no_copy(No_copy, TopXMLNS); do_encode({hint, 'no-store'} = No_store, TopXMLNS) -> encode_hint_no_store(No_store, TopXMLNS); do_encode({hint, 'no-storage'} = No_storage, TopXMLNS) -> encode_hint_no_storage(No_storage, TopXMLNS); do_encode({hint, store} = Store, TopXMLNS) -> encode_hint_store(Store, TopXMLNS); do_encode({hint, 'no-permanent-store'} = No_permanent_store, TopXMLNS) -> encode_hint_no_permanent_store(No_permanent_store, TopXMLNS); do_encode({hint, 'no-permanent-storage'} = No_permanent_storage, TopXMLNS) -> encode_hint_no_permanent_storage(No_permanent_storage, TopXMLNS). do_get_name({hint, 'no-copy'}) -> <<"no-copy">>; do_get_name({hint, 'no-permanent-storage'}) -> <<"no-permanent-storage">>; do_get_name({hint, 'no-permanent-store'}) -> <<"no-permanent-store">>; do_get_name({hint, 'no-storage'}) -> <<"no-storage">>; do_get_name({hint, 'no-store'}) -> <<"no-store">>; do_get_name({hint, store}) -> <<"store">>. do_get_ns({hint, 'no-copy'}) -> <<"urn:xmpp:hints">>; do_get_ns({hint, 'no-permanent-storage'}) -> <<"urn:xmpp:hints">>; do_get_ns({hint, 'no-permanent-store'}) -> <<"urn:xmpp:hints">>; do_get_ns({hint, 'no-storage'}) -> <<"urn:xmpp:hints">>; do_get_ns({hint, 'no-store'}) -> <<"urn:xmpp:hints">>; do_get_ns({hint, store}) -> <<"urn:xmpp:hints">>. pp(hint, 1) -> [type]; pp(_, _) -> no. records() -> [{hint, 1}]. decode_hint_no_permanent_storage(__TopXMLNS, __Opts, {xmlel, <<"no-permanent-storage">>, _attrs, _els}) -> {hint, 'no-permanent-storage'}. encode_hint_no_permanent_storage({hint, 'no-permanent-storage'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hints">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"no-permanent-storage">>, _attrs, _els}. decode_hint_no_permanent_store(__TopXMLNS, __Opts, {xmlel, <<"no-permanent-store">>, _attrs, _els}) -> {hint, 'no-permanent-store'}. encode_hint_no_permanent_store({hint, 'no-permanent-store'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hints">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"no-permanent-store">>, _attrs, _els}. decode_hint_store(__TopXMLNS, __Opts, {xmlel, <<"store">>, _attrs, _els}) -> {hint, store}. encode_hint_store({hint, store}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hints">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"store">>, _attrs, _els}. decode_hint_no_storage(__TopXMLNS, __Opts, {xmlel, <<"no-storage">>, _attrs, _els}) -> {hint, 'no-storage'}. encode_hint_no_storage({hint, 'no-storage'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hints">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"no-storage">>, _attrs, _els}. decode_hint_no_store(__TopXMLNS, __Opts, {xmlel, <<"no-store">>, _attrs, _els}) -> {hint, 'no-store'}. encode_hint_no_store({hint, 'no-store'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hints">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"no-store">>, _attrs, _els}. decode_hint_no_copy(__TopXMLNS, __Opts, {xmlel, <<"no-copy">>, _attrs, _els}) -> {hint, 'no-copy'}. encode_hint_no_copy({hint, 'no-copy'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hints">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"no-copy">>, _attrs, _els}. xmpp-1.4.4/src/xep0221.erl0000644000232200023220000001412513610066730015453 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0221). -compile(export_all). do_decode(<<"media">>, <<"urn:xmpp:media-element">>, El, Opts) -> decode_media(<<"urn:xmpp:media-element">>, Opts, El); do_decode(<<"uri">>, <<"urn:xmpp:media-element">>, El, Opts) -> decode_media_uri(<<"urn:xmpp:media-element">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"media">>, <<"urn:xmpp:media-element">>}, {<<"uri">>, <<"urn:xmpp:media-element">>}]. do_encode({media_uri, _, _} = Uri, TopXMLNS) -> encode_media_uri(Uri, TopXMLNS); do_encode({media, _, _, _} = Media, TopXMLNS) -> encode_media(Media, TopXMLNS). do_get_name({media, _, _, _}) -> <<"media">>; do_get_name({media_uri, _, _}) -> <<"uri">>. do_get_ns({media, _, _, _}) -> <<"urn:xmpp:media-element">>; do_get_ns({media_uri, _, _}) -> <<"urn:xmpp:media-element">>. pp(media_uri, 2) -> [type, uri]; pp(media, 3) -> [height, width, uri]; pp(_, _) -> no. records() -> [{media_uri, 2}, {media, 3}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_media(__TopXMLNS, __Opts, {xmlel, <<"media">>, _attrs, _els}) -> Uri = decode_media_els(__TopXMLNS, __Opts, _els, []), {Height, Width} = decode_media_attrs(__TopXMLNS, _attrs, undefined, undefined), {media, Height, Width, Uri}. decode_media_els(__TopXMLNS, __Opts, [], Uri) -> lists:reverse(Uri); decode_media_els(__TopXMLNS, __Opts, [{xmlel, <<"uri">>, _attrs, _} = _el | _els], Uri) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:media-element">> -> decode_media_els(__TopXMLNS, __Opts, _els, [decode_media_uri(<<"urn:xmpp:media-element">>, __Opts, _el) | Uri]); _ -> decode_media_els(__TopXMLNS, __Opts, _els, Uri) end; decode_media_els(__TopXMLNS, __Opts, [_ | _els], Uri) -> decode_media_els(__TopXMLNS, __Opts, _els, Uri). decode_media_attrs(__TopXMLNS, [{<<"height">>, _val} | _attrs], _Height, Width) -> decode_media_attrs(__TopXMLNS, _attrs, _val, Width); decode_media_attrs(__TopXMLNS, [{<<"width">>, _val} | _attrs], Height, _Width) -> decode_media_attrs(__TopXMLNS, _attrs, Height, _val); decode_media_attrs(__TopXMLNS, [_ | _attrs], Height, Width) -> decode_media_attrs(__TopXMLNS, _attrs, Height, Width); decode_media_attrs(__TopXMLNS, [], Height, Width) -> {decode_media_attr_height(__TopXMLNS, Height), decode_media_attr_width(__TopXMLNS, Width)}. encode_media({media, Height, Width, Uri}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:media-element">>, [], __TopXMLNS), _els = lists:reverse('encode_media_$uri'(Uri, __NewTopXMLNS, [])), _attrs = encode_media_attr_width(Width, encode_media_attr_height(Height, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"media">>, _attrs, _els}. 'encode_media_$uri'([], __TopXMLNS, _acc) -> _acc; 'encode_media_$uri'([Uri | _els], __TopXMLNS, _acc) -> 'encode_media_$uri'(_els, __TopXMLNS, [encode_media_uri(Uri, __TopXMLNS) | _acc]). decode_media_attr_height(__TopXMLNS, undefined) -> undefined; decode_media_attr_height(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"height">>, <<"media">>, __TopXMLNS}}); _res -> _res end. encode_media_attr_height(undefined, _acc) -> _acc; encode_media_attr_height(_val, _acc) -> [{<<"height">>, enc_int(_val)} | _acc]. decode_media_attr_width(__TopXMLNS, undefined) -> undefined; decode_media_attr_width(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"width">>, <<"media">>, __TopXMLNS}}); _res -> _res end. encode_media_attr_width(undefined, _acc) -> _acc; encode_media_attr_width(_val, _acc) -> [{<<"width">>, enc_int(_val)} | _acc]. decode_media_uri(__TopXMLNS, __Opts, {xmlel, <<"uri">>, _attrs, _els}) -> Uri = decode_media_uri_els(__TopXMLNS, __Opts, _els, <<>>), Type = decode_media_uri_attrs(__TopXMLNS, _attrs, undefined), {media_uri, Type, Uri}. decode_media_uri_els(__TopXMLNS, __Opts, [], Uri) -> decode_media_uri_cdata(__TopXMLNS, Uri); decode_media_uri_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Uri) -> decode_media_uri_els(__TopXMLNS, __Opts, _els, <>); decode_media_uri_els(__TopXMLNS, __Opts, [_ | _els], Uri) -> decode_media_uri_els(__TopXMLNS, __Opts, _els, Uri). decode_media_uri_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], _Type) -> decode_media_uri_attrs(__TopXMLNS, _attrs, _val); decode_media_uri_attrs(__TopXMLNS, [_ | _attrs], Type) -> decode_media_uri_attrs(__TopXMLNS, _attrs, Type); decode_media_uri_attrs(__TopXMLNS, [], Type) -> decode_media_uri_attr_type(__TopXMLNS, Type). encode_media_uri({media_uri, Type, Uri}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:media-element">>, [], __TopXMLNS), _els = encode_media_uri_cdata(Uri, []), _attrs = encode_media_uri_attr_type(Type, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"uri">>, _attrs, _els}. decode_media_uri_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"uri">>, __TopXMLNS}}); decode_media_uri_attr_type(__TopXMLNS, _val) -> _val. encode_media_uri_attr_type(_val, _acc) -> [{<<"type">>, _val} | _acc]. decode_media_uri_cdata(__TopXMLNS, <<>>) -> <<>>; decode_media_uri_cdata(__TopXMLNS, _val) -> _val. encode_media_uri_cdata(<<>>, _acc) -> _acc; encode_media_uri_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xmpp_sasl_digest.erl0000644000232200023220000001770113610066730017722 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_sasl_digest). -behaviour(xmpp_sasl). -author('alexey@sevcom.net'). -dialyzer({no_match, [get_local_fqdn/1]}). -export([mech_new/4, mech_step/2, format_error/1]). %% For tests -export([parse/1]). -type get_password_fun() :: fun((binary()) -> {false, any()} | {binary(), atom()}). -type check_password_fun() :: fun((binary(), binary(), binary(), binary(), fun((binary()) -> binary())) -> {boolean(), any()} | false). -type error_reason() :: parser_failed | invalid_digest_uri | not_authorized | unexpected_response. -export_type([error_reason/0]). -record(state, {step = 1 :: 1 | 3 | 5, nonce = <<"">> :: binary(), username = <<"">> :: binary(), authzid = <<"">> :: binary(), get_password :: get_password_fun(), check_password :: check_password_fun(), auth_module :: atom(), host = <<"">> :: binary(), hostfqdn = [] :: [binary()]}). -spec format_error(error_reason()) -> {atom(), binary()}. format_error(parser_failed) -> {'bad-protocol', <<"Response decoding failed">>}; format_error(invalid_digest_uri) -> {'bad-protocol', <<"Invalid digest URI">>}; format_error(not_authorized) -> {'not-authorized', <<"Invalid username or password">>}; format_error(unexpected_response) -> {'bad-protocol', <<"Unexpected response">>}. mech_new(Host, GetPassword, _CheckPassword, CheckPasswordDigest) -> #state{step = 1, nonce = p1_rand:get_string(), host = Host, hostfqdn = get_local_fqdn(Host), get_password = GetPassword, check_password = CheckPasswordDigest}. mech_step(#state{step = 1, nonce = Nonce} = State, _) -> {continue, <<"nonce=\"", Nonce/binary, "\",qop=\"auth\",charset=utf-8,algorithm=md5-sess">>, State#state{step = 3}}; mech_step(#state{step = 3, nonce = Nonce} = State, ClientIn) -> case parse(ClientIn) of bad -> {error, parser_failed}; KeyVals -> DigestURI = proplists:get_value(<<"digest-uri">>, KeyVals, <<>>), UserName = proplists:get_value(<<"username">>, KeyVals, <<>>), case is_digesturi_valid(DigestURI, State#state.host, State#state.hostfqdn) of false -> {error, invalid_digest_uri, UserName}; true -> AuthzId = proplists:get_value(<<"authzid">>, KeyVals, <<>>), case (State#state.get_password)(UserName) of {false, _} -> {error, not_authorized, UserName}; {Passwd, AuthModule} -> case (State#state.check_password)(UserName, UserName, <<"">>, proplists:get_value(<<"response">>, KeyVals, <<>>), fun (PW) -> response(KeyVals, UserName, PW, Nonce, AuthzId, <<"AUTHENTICATE">>) end) of {true, _} -> RspAuth = response(KeyVals, UserName, Passwd, Nonce, AuthzId, <<"">>), {continue, <<"rspauth=", RspAuth/binary>>, State#state{step = 5, auth_module = AuthModule, username = UserName, authzid = AuthzId}}; false -> {error, not_authorized, UserName}; {false, _} -> {error, not_authorized, UserName} end end end end; mech_step(#state{step = 5, auth_module = AuthModule, username = UserName, authzid = AuthzId}, <<"">>) -> {ok, [{username, UserName}, {authzid, case AuthzId of <<"">> -> UserName; _ -> AuthzId end }, {auth_module, AuthModule}]}; mech_step(_, _) -> {error, unexpected_response}. parse(S) -> parse1(binary_to_list(S), "", []). parse1([$= | Cs], S, Ts) -> parse2(Cs, lists:reverse(S), "", Ts); parse1([$, | Cs], [], Ts) -> parse1(Cs, [], Ts); parse1([$\s | Cs], [], Ts) -> parse1(Cs, [], Ts); parse1([C | Cs], S, Ts) -> parse1(Cs, [C | S], Ts); parse1([], [], T) -> lists:reverse(T); parse1([], _S, _T) -> bad. parse2([$" | Cs], Key, Val, Ts) -> parse3(Cs, Key, Val, Ts); parse2([C | Cs], Key, Val, Ts) -> parse4(Cs, Key, [C | Val], Ts); parse2([], _, _, _) -> bad. parse3([$" | Cs], Key, Val, Ts) -> parse4(Cs, Key, Val, Ts); parse3([$\\, C | Cs], Key, Val, Ts) -> parse3(Cs, Key, [C | Val], Ts); parse3([C | Cs], Key, Val, Ts) -> parse3(Cs, Key, [C | Val], Ts); parse3([], _, _, _) -> bad. parse4([$, | Cs], Key, Val, Ts) -> parse1(Cs, "", [{list_to_binary(Key), list_to_binary(lists:reverse(Val))} | Ts]); parse4([$\s | Cs], Key, Val, Ts) -> parse4(Cs, Key, Val, Ts); parse4([C | Cs], Key, Val, Ts) -> parse4(Cs, Key, [C | Val], Ts); parse4([], Key, Val, Ts) -> %% @doc Check if the digest-uri is valid. %% RFC-2831 allows to provide the IP address in Host, %% however this is not supported %% If the service (for example jabber.example.org) %% is provided by several hosts (being one of them server3.example.org), %% then acceptable digest-uris would be: %% xmpp/server3.example.org/jabber.example.org, xmpp/server3.example.org and %% xmpp/jabber.example.org %% The last version is not actually allowed by the RFC, but implemented by popular clients parse1([], "", [{list_to_binary(Key), list_to_binary(lists:reverse(Val))} | Ts]). is_digesturi_valid(DigestURICase, JabberDomain, JabberFQDN) -> DigestURI = stringprep:tolower(DigestURICase), case binary:split(DigestURI, <<$/>>, [global, trim]) of [<<"xmpp">>, Host] -> IsHostFqdn = is_host_fqdn(Host, JabberFQDN), (Host == JabberDomain) or IsHostFqdn; [<<"xmpp">>, Host, ServName] -> IsHostFqdn = is_host_fqdn(Host, JabberFQDN), (ServName == JabberDomain) and IsHostFqdn; _ -> false end. is_host_fqdn(_Host, []) -> false; is_host_fqdn(Host, [Fqdn | _FqdnTail]) when Host == Fqdn -> true; is_host_fqdn(Host, [Fqdn | FqdnTail]) when Host /= Fqdn -> is_host_fqdn(Host, FqdnTail). get_local_fqdn(Host) -> {ok, FQDNs} = xmpp_config:fqdn(Host), case FQDNs of [] -> [Host]; _ -> FQDNs end. hex(S) -> xmpp_util:hex(S). proplists_get_bin_value(Key, Pairs, Default) -> case proplists:get_value(Key, Pairs, Default) of L when is_list(L) -> list_to_binary(L); L2 -> L2 end. response(KeyVals, User, Passwd, Nonce, AuthzId, A2Prefix) -> Realm = proplists_get_bin_value(<<"realm">>, KeyVals, <<>>), CNonce = proplists_get_bin_value(<<"cnonce">>, KeyVals, <<>>), DigestURI = proplists_get_bin_value(<<"digest-uri">>, KeyVals, <<>>), NC = proplists_get_bin_value(<<"nc">>, KeyVals, <<>>), QOP = proplists_get_bin_value(<<"qop">>, KeyVals, <<>>), MD5Hash = erlang:md5(<>), A1 = case AuthzId of <<"">> -> <>; _ -> <> end, A2 = case QOP of <<"auth">> -> <>; _ -> <> end, T = <<(hex((erlang:md5(A1))))/binary, ":", Nonce/binary, ":", NC/binary, ":", CNonce/binary, ":", QOP/binary, ":", (hex((erlang:md5(A2))))/binary>>, hex((erlang:md5(T))). xmpp-1.4.4/src/xmpp_sasl.erl0000644000232200023220000001340613610066730016361 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_sasl). -author('alexey@process-one.net'). -export([server_new/4, server_start/3, server_step/2, listmech/0, format_error/2]). %% TODO: write correct types for these callbacks -type get_password_fun() :: fun(). -type check_password_fun() :: fun(). -type check_password_digest_fun() :: fun(). -record(sasl_state, {server_host :: binary(), mech_name = <<"">> :: mechanism(), mech_state :: mech_state(), get_password :: get_password_fun(), check_password :: check_password_fun(), check_password_digest :: check_password_digest_fun()}). -type mechanism() :: binary(). -type mech_state() :: term(). -type sasl_module() :: xmpp_sasl_anonymous | xmpp_sasl_digest | xmpp_sasl_oauth | xmpp_sasl_plain | xmpp_sasl_scram. -type sasl_state() :: #sasl_state{}. -type sasl_property() :: {username, binary()} | {authzid, binary()} | {mechanism, binary()} | {auth_module, atom()}. -type sasl_return() :: {ok, [sasl_property()]} | {ok, [sasl_property()], binary()} | {continue, binary(), sasl_state()} | {error, error_reason(), binary()}. -type error_reason() :: xmpp_sasl_digest:error_reason() | xmpp_sasl_oauth:error_reason() | xmpp_sasl_plain:error_reason() | xmpp_sasl_scram:error_reason() | unsupported_mechanism | nodeprep_failed | empty_username | aborted. -export_type([mechanism/0, error_reason/0, sasl_state/0, sasl_return/0, sasl_property/0]). -callback mech_new(binary(), get_password_fun(), check_password_fun(), check_password_digest_fun()) -> mech_state(). -callback mech_step(mech_state(), binary()) -> sasl_return(). %%%=================================================================== %%% API %%%=================================================================== -spec format_error(mechanism(), error_reason()) -> {atom(), binary()}. format_error(_, unsupported_mechanism) -> {'invalid-mechanism', <<"Unsupported mechanism">>}; format_error(_, nodeprep_failed) -> {'bad-protocol', <<"Nodeprep failed">>}; format_error(_, empty_username) -> {'bad-protocol', <<"Empty username">>}; format_error(_, aborted) -> {'aborted', <<"Aborted">>}; format_error(Mech, Reason) -> case get_mod(Mech) of undefined -> {'invalid-mechanism', <<"Unsupported mechanism">>}; Mod -> Mod:format_error(Reason) end. -spec listmech() -> [mechanism()]. listmech() -> [<<"ANONYMOUS">>,<<"DIGEST-MD5">>,<<"PLAIN">>, <<"SCRAM-SHA-1">>,<<"X-OAUTH2">>]. -spec server_new(binary(), get_password_fun(), check_password_fun(), check_password_digest_fun()) -> sasl_state(). server_new(ServerHost, GetPassword, CheckPassword, CheckPasswordDigest) -> #sasl_state{server_host = ServerHost, get_password = GetPassword, check_password = CheckPassword, check_password_digest = CheckPasswordDigest}. -spec server_start(sasl_state(), mechanism(), binary()) -> sasl_return(). server_start(State, Mech, ClientIn) -> case get_mod(Mech) of undefined -> {error, unsupported_mechanism, <<"">>}; Module -> MechState = Module:mech_new(State#sasl_state.server_host, State#sasl_state.get_password, State#sasl_state.check_password, State#sasl_state.check_password_digest), State1 = State#sasl_state{mech_name = Mech, mech_state = MechState}, server_step(State1, ClientIn) end. -spec server_step(sasl_state(), binary()) -> sasl_return(). server_step(State, ClientIn) -> Module = get_mod(State#sasl_state.mech_name), MechState = State#sasl_state.mech_state, case Module:mech_step(MechState, ClientIn) of {ok, Props} -> case check_credentials(Props) of ok -> {ok, Props}; {error, Error} -> {error, Error, <<"">>} end; {ok, Props, ServerOut} -> case check_credentials(Props) of ok -> {ok, Props, ServerOut}; {error, Error} -> {error, Error, <<"">>} end; {continue, ServerOut, NewMechState} -> {continue, ServerOut, State#sasl_state{mech_state = NewMechState}}; {error, Error, Username} -> {error, Error, Username}; {error, Error} -> {error, Error, <<"">>} end. %%%=================================================================== %%% Internal functions %%%=================================================================== -spec check_credentials([sasl_property()]) -> ok | {error, error_reason()}. check_credentials(Props) -> User = proplists:get_value(authzid, Props, <<>>), case jid:nodeprep(User) of error -> {error, nodeprep_failed}; <<"">> -> {error, empty_username}; _LUser -> ok end. -spec get_mod(binary()) -> sasl_module() | undefined. get_mod(<<"ANONYMOUS">>) -> xmpp_sasl_anonymous; get_mod(<<"DIGEST-MD5">>) -> xmpp_sasl_digest; get_mod(<<"X-OAUTH2">>) -> xmpp_sasl_oauth; get_mod(<<"PLAIN">>) -> xmpp_sasl_plain; get_mod(<<"SCRAM-SHA-1">>) -> xmpp_sasl_scram; get_mod(_) -> undefined. xmpp-1.4.4/src/xep0202.erl0000644000232200023220000001316313610066730015453 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0202). -compile(export_all). do_decode(<<"time">>, <<"urn:xmpp:time">>, El, Opts) -> decode_time(<<"urn:xmpp:time">>, Opts, El); do_decode(<<"tzo">>, <<"urn:xmpp:time">>, El, Opts) -> decode_time_tzo(<<"urn:xmpp:time">>, Opts, El); do_decode(<<"utc">>, <<"urn:xmpp:time">>, El, Opts) -> decode_time_utc(<<"urn:xmpp:time">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"time">>, <<"urn:xmpp:time">>}, {<<"tzo">>, <<"urn:xmpp:time">>}, {<<"utc">>, <<"urn:xmpp:time">>}]. do_encode({time, _, _} = Time, TopXMLNS) -> encode_time(Time, TopXMLNS). do_get_name({time, _, _}) -> <<"time">>. do_get_ns({time, _, _}) -> <<"urn:xmpp:time">>. pp(time, 2) -> [tzo, utc]; pp(_, _) -> no. records() -> [{time, 2}]. dec_tzo(Val) -> [H1, M1] = binary:split(Val, <<":">>), H = binary_to_integer(H1), M = binary_to_integer(M1), if H >= -12, H =< 12, M >= 0, M < 60 -> {H, M} end. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_tzo({H, M}) -> Sign = if H >= 0 -> <<>>; true -> <<"-">> end, list_to_binary([Sign, io_lib:format("~2..0w:~2..0w", [abs(H), M])]). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_time(__TopXMLNS, __Opts, {xmlel, <<"time">>, _attrs, _els}) -> {Utc, Tzo} = decode_time_els(__TopXMLNS, __Opts, _els, undefined, undefined), {time, Tzo, Utc}. decode_time_els(__TopXMLNS, __Opts, [], Utc, Tzo) -> {Utc, Tzo}; decode_time_els(__TopXMLNS, __Opts, [{xmlel, <<"tzo">>, _attrs, _} = _el | _els], Utc, Tzo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:time">> -> decode_time_els(__TopXMLNS, __Opts, _els, Utc, decode_time_tzo(<<"urn:xmpp:time">>, __Opts, _el)); _ -> decode_time_els(__TopXMLNS, __Opts, _els, Utc, Tzo) end; decode_time_els(__TopXMLNS, __Opts, [{xmlel, <<"utc">>, _attrs, _} = _el | _els], Utc, Tzo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:time">> -> decode_time_els(__TopXMLNS, __Opts, _els, decode_time_utc(<<"urn:xmpp:time">>, __Opts, _el), Tzo); _ -> decode_time_els(__TopXMLNS, __Opts, _els, Utc, Tzo) end; decode_time_els(__TopXMLNS, __Opts, [_ | _els], Utc, Tzo) -> decode_time_els(__TopXMLNS, __Opts, _els, Utc, Tzo). encode_time({time, Tzo, Utc}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:time">>, [], __TopXMLNS), _els = lists:reverse('encode_time_$utc'(Utc, __NewTopXMLNS, 'encode_time_$tzo'(Tzo, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"time">>, _attrs, _els}. 'encode_time_$utc'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_time_$utc'(Utc, __TopXMLNS, _acc) -> [encode_time_utc(Utc, __TopXMLNS) | _acc]. 'encode_time_$tzo'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_time_$tzo'(Tzo, __TopXMLNS, _acc) -> [encode_time_tzo(Tzo, __TopXMLNS) | _acc]. decode_time_tzo(__TopXMLNS, __Opts, {xmlel, <<"tzo">>, _attrs, _els}) -> Cdata = decode_time_tzo_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_time_tzo_els(__TopXMLNS, __Opts, [], Cdata) -> decode_time_tzo_cdata(__TopXMLNS, Cdata); decode_time_tzo_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_time_tzo_els(__TopXMLNS, __Opts, _els, <>); decode_time_tzo_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_time_tzo_els(__TopXMLNS, __Opts, _els, Cdata). encode_time_tzo(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:time">>, [], __TopXMLNS), _els = encode_time_tzo_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"tzo">>, _attrs, _els}. decode_time_tzo_cdata(__TopXMLNS, <<>>) -> undefined; decode_time_tzo_cdata(__TopXMLNS, _val) -> case catch dec_tzo(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"tzo">>, __TopXMLNS}}); _res -> _res end. encode_time_tzo_cdata(undefined, _acc) -> _acc; encode_time_tzo_cdata(_val, _acc) -> [{xmlcdata, enc_tzo(_val)} | _acc]. decode_time_utc(__TopXMLNS, __Opts, {xmlel, <<"utc">>, _attrs, _els}) -> Cdata = decode_time_utc_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_time_utc_els(__TopXMLNS, __Opts, [], Cdata) -> decode_time_utc_cdata(__TopXMLNS, Cdata); decode_time_utc_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_time_utc_els(__TopXMLNS, __Opts, _els, <>); decode_time_utc_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_time_utc_els(__TopXMLNS, __Opts, _els, Cdata). encode_time_utc(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:time">>, [], __TopXMLNS), _els = encode_time_utc_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"utc">>, _attrs, _els}. decode_time_utc_cdata(__TopXMLNS, <<>>) -> undefined; decode_time_utc_cdata(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"utc">>, __TopXMLNS}}); _res -> _res end. encode_time_utc_cdata(undefined, _acc) -> _acc; encode_time_utc_cdata(_val, _acc) -> [{xmlcdata, enc_utc(_val)} | _acc]. xmpp-1.4.4/src/xep0297.erl0000644000232200023220000000516513610066730015474 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0297). -compile(export_all). do_decode(<<"forwarded">>, <<"urn:xmpp:forward:0">>, El, Opts) -> decode_forwarded(<<"urn:xmpp:forward:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"forwarded">>, <<"urn:xmpp:forward:0">>}]. do_encode({forwarded, _, _} = Forwarded, TopXMLNS) -> encode_forwarded(Forwarded, TopXMLNS). do_get_name({forwarded, _, _}) -> <<"forwarded">>. do_get_ns({forwarded, _, _}) -> <<"urn:xmpp:forward:0">>. get_els({forwarded, _delay, _sub_els}) -> _sub_els. set_els({forwarded, _delay, _}, _sub_els) -> {forwarded, _delay, _sub_els}. pp(forwarded, 2) -> [delay, sub_els]; pp(_, _) -> no. records() -> [{forwarded, 2}]. decode_forwarded(__TopXMLNS, __Opts, {xmlel, <<"forwarded">>, _attrs, _els}) -> {Delay, __Els} = decode_forwarded_els(__TopXMLNS, __Opts, _els, undefined, []), {forwarded, Delay, __Els}. decode_forwarded_els(__TopXMLNS, __Opts, [], Delay, __Els) -> {Delay, lists:reverse(__Els)}; decode_forwarded_els(__TopXMLNS, __Opts, [{xmlel, <<"delay">>, _attrs, _} = _el | _els], Delay, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:delay">> -> decode_forwarded_els(__TopXMLNS, __Opts, _els, xep0203:decode_delay(<<"urn:xmpp:delay">>, __Opts, _el), __Els); _ -> decode_forwarded_els(__TopXMLNS, __Opts, _els, Delay, [_el | __Els]) end; decode_forwarded_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Delay, __Els) -> decode_forwarded_els(__TopXMLNS, __Opts, _els, Delay, [_el | __Els]); decode_forwarded_els(__TopXMLNS, __Opts, [_ | _els], Delay, __Els) -> decode_forwarded_els(__TopXMLNS, __Opts, _els, Delay, __Els). encode_forwarded({forwarded, Delay, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:forward:0">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_forwarded_$delay'(Delay, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"forwarded">>, _attrs, _els}. 'encode_forwarded_$delay'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_forwarded_$delay'(Delay, __TopXMLNS, _acc) -> [xep0203:encode_delay(Delay, __TopXMLNS) | _acc]. xmpp-1.4.4/src/xep0264.erl0000644000232200023220000001106313610066730015460 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0264). -compile(export_all). do_decode(<<"thumbnail">>, <<"urn:xmpp:thumbs:1">>, El, Opts) -> decode_thumbnail(<<"urn:xmpp:thumbs:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"thumbnail">>, <<"urn:xmpp:thumbs:1">>}]. do_encode({thumbnail, _, _, _, _} = Thumbnail, TopXMLNS) -> encode_thumbnail(Thumbnail, TopXMLNS). do_get_name({thumbnail, _, _, _, _}) -> <<"thumbnail">>. do_get_ns({thumbnail, _, _, _, _}) -> <<"urn:xmpp:thumbs:1">>. pp(thumbnail, 4) -> [uri, 'media-type', width, height]; pp(_, _) -> no. records() -> [{thumbnail, 4}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_thumbnail(__TopXMLNS, __Opts, {xmlel, <<"thumbnail">>, _attrs, _els}) -> {Uri, Media_type, Width, Height} = decode_thumbnail_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {thumbnail, Uri, Media_type, Width, Height}. decode_thumbnail_attrs(__TopXMLNS, [{<<"uri">>, _val} | _attrs], _Uri, Media_type, Width, Height) -> decode_thumbnail_attrs(__TopXMLNS, _attrs, _val, Media_type, Width, Height); decode_thumbnail_attrs(__TopXMLNS, [{<<"media-type">>, _val} | _attrs], Uri, _Media_type, Width, Height) -> decode_thumbnail_attrs(__TopXMLNS, _attrs, Uri, _val, Width, Height); decode_thumbnail_attrs(__TopXMLNS, [{<<"width">>, _val} | _attrs], Uri, Media_type, _Width, Height) -> decode_thumbnail_attrs(__TopXMLNS, _attrs, Uri, Media_type, _val, Height); decode_thumbnail_attrs(__TopXMLNS, [{<<"height">>, _val} | _attrs], Uri, Media_type, Width, _Height) -> decode_thumbnail_attrs(__TopXMLNS, _attrs, Uri, Media_type, Width, _val); decode_thumbnail_attrs(__TopXMLNS, [_ | _attrs], Uri, Media_type, Width, Height) -> decode_thumbnail_attrs(__TopXMLNS, _attrs, Uri, Media_type, Width, Height); decode_thumbnail_attrs(__TopXMLNS, [], Uri, Media_type, Width, Height) -> {decode_thumbnail_attr_uri(__TopXMLNS, Uri), 'decode_thumbnail_attr_media-type'(__TopXMLNS, Media_type), decode_thumbnail_attr_width(__TopXMLNS, Width), decode_thumbnail_attr_height(__TopXMLNS, Height)}. encode_thumbnail({thumbnail, Uri, Media_type, Width, Height}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:thumbs:1">>, [], __TopXMLNS), _els = [], _attrs = encode_thumbnail_attr_height(Height, encode_thumbnail_attr_width(Width, 'encode_thumbnail_attr_media-type'(Media_type, encode_thumbnail_attr_uri(Uri, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"thumbnail">>, _attrs, _els}. decode_thumbnail_attr_uri(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"uri">>, <<"thumbnail">>, __TopXMLNS}}); decode_thumbnail_attr_uri(__TopXMLNS, _val) -> _val. encode_thumbnail_attr_uri(_val, _acc) -> [{<<"uri">>, _val} | _acc]. 'decode_thumbnail_attr_media-type'(__TopXMLNS, undefined) -> <<>>; 'decode_thumbnail_attr_media-type'(__TopXMLNS, _val) -> _val. 'encode_thumbnail_attr_media-type'(<<>>, _acc) -> _acc; 'encode_thumbnail_attr_media-type'(_val, _acc) -> [{<<"media-type">>, _val} | _acc]. decode_thumbnail_attr_width(__TopXMLNS, undefined) -> undefined; decode_thumbnail_attr_width(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"width">>, <<"thumbnail">>, __TopXMLNS}}); _res -> _res end. encode_thumbnail_attr_width(undefined, _acc) -> _acc; encode_thumbnail_attr_width(_val, _acc) -> [{<<"width">>, enc_int(_val)} | _acc]. decode_thumbnail_attr_height(__TopXMLNS, undefined) -> undefined; decode_thumbnail_attr_height(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"height">>, <<"thumbnail">>, __TopXMLNS}}); _res -> _res end. encode_thumbnail_attr_height(undefined, _acc) -> _acc; encode_thumbnail_attr_height(_val, _acc) -> [{<<"height">>, enc_int(_val)} | _acc]. xmpp-1.4.4/src/xep0198.erl0000644000232200023220000011254113610066730015471 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0198). -compile(export_all). do_decode(<<"failed">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_sm_failed(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"failed">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_sm_failed(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(<<"a">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_sm_a(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"a">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_sm_a(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(<<"r">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_sm_r(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"r">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_sm_r(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(<<"resumed">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_sm_resumed(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"resumed">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_sm_resumed(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(<<"resume">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_sm_resume(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"resume">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_sm_resume(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(<<"enabled">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_sm_enabled(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"enabled">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_sm_enabled(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(<<"enable">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_sm_enable(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"enable">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_sm_enable(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(<<"sm">>, <<"urn:xmpp:sm:2">>, El, Opts) -> decode_feature_sm(<<"urn:xmpp:sm:2">>, Opts, El); do_decode(<<"sm">>, <<"urn:xmpp:sm:3">>, El, Opts) -> decode_feature_sm(<<"urn:xmpp:sm:3">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"failed">>, <<"urn:xmpp:sm:2">>}, {<<"failed">>, <<"urn:xmpp:sm:3">>}, {<<"a">>, <<"urn:xmpp:sm:2">>}, {<<"a">>, <<"urn:xmpp:sm:3">>}, {<<"r">>, <<"urn:xmpp:sm:2">>}, {<<"r">>, <<"urn:xmpp:sm:3">>}, {<<"resumed">>, <<"urn:xmpp:sm:2">>}, {<<"resumed">>, <<"urn:xmpp:sm:3">>}, {<<"resume">>, <<"urn:xmpp:sm:2">>}, {<<"resume">>, <<"urn:xmpp:sm:3">>}, {<<"enabled">>, <<"urn:xmpp:sm:2">>}, {<<"enabled">>, <<"urn:xmpp:sm:3">>}, {<<"enable">>, <<"urn:xmpp:sm:2">>}, {<<"enable">>, <<"urn:xmpp:sm:3">>}, {<<"sm">>, <<"urn:xmpp:sm:2">>}, {<<"sm">>, <<"urn:xmpp:sm:3">>}]. do_encode({feature_sm, _} = Sm, TopXMLNS) -> encode_feature_sm(Sm, TopXMLNS); do_encode({sm_enable, _, _, _} = Enable, TopXMLNS) -> encode_sm_enable(Enable, TopXMLNS); do_encode({sm_enabled, _, _, _, _, _} = Enabled, TopXMLNS) -> encode_sm_enabled(Enabled, TopXMLNS); do_encode({sm_resume, _, _, _} = Resume, TopXMLNS) -> encode_sm_resume(Resume, TopXMLNS); do_encode({sm_resumed, _, _, _} = Resumed, TopXMLNS) -> encode_sm_resumed(Resumed, TopXMLNS); do_encode({sm_r, _} = R, TopXMLNS) -> encode_sm_r(R, TopXMLNS); do_encode({sm_a, _, _} = A, TopXMLNS) -> encode_sm_a(A, TopXMLNS); do_encode({sm_failed, _, _, _, _} = Failed, TopXMLNS) -> encode_sm_failed(Failed, TopXMLNS). do_get_name({feature_sm, _}) -> <<"sm">>; do_get_name({sm_a, _, _}) -> <<"a">>; do_get_name({sm_enable, _, _, _}) -> <<"enable">>; do_get_name({sm_enabled, _, _, _, _, _}) -> <<"enabled">>; do_get_name({sm_failed, _, _, _, _}) -> <<"failed">>; do_get_name({sm_r, _}) -> <<"r">>; do_get_name({sm_resume, _, _, _}) -> <<"resume">>; do_get_name({sm_resumed, _, _, _}) -> <<"resumed">>. do_get_ns({feature_sm, Xmlns}) -> Xmlns; do_get_ns({sm_a, _, Xmlns}) -> Xmlns; do_get_ns({sm_enable, _, _, Xmlns}) -> Xmlns; do_get_ns({sm_enabled, _, _, _, _, Xmlns}) -> Xmlns; do_get_ns({sm_failed, _, _, _, Xmlns}) -> Xmlns; do_get_ns({sm_r, Xmlns}) -> Xmlns; do_get_ns({sm_resume, _, _, Xmlns}) -> Xmlns; do_get_ns({sm_resumed, _, _, Xmlns}) -> Xmlns. pp(feature_sm, 1) -> [xmlns]; pp(sm_enable, 3) -> [max, resume, xmlns]; pp(sm_enabled, 5) -> [id, location, max, resume, xmlns]; pp(sm_resume, 3) -> [h, previd, xmlns]; pp(sm_resumed, 3) -> [h, previd, xmlns]; pp(sm_r, 1) -> [xmlns]; pp(sm_a, 2) -> [h, xmlns]; pp(sm_failed, 4) -> [reason, text, h, xmlns]; pp(_, _) -> no. records() -> [{feature_sm, 1}, {sm_enable, 3}, {sm_enabled, 5}, {sm_resume, 3}, {sm_resumed, 3}, {sm_r, 1}, {sm_a, 2}, {sm_failed, 4}]. dec_bool(<<"false">>) -> false; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"1">>) -> true. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_bool(false) -> <<"false">>; enc_bool(true) -> <<"true">>. enc_int(Int) -> erlang:integer_to_binary(Int). decode_sm_failed(__TopXMLNS, __Opts, {xmlel, <<"failed">>, _attrs, _els}) -> {Text, Reason} = decode_sm_failed_els(__TopXMLNS, __Opts, _els, [], undefined), {H, Xmlns} = decode_sm_failed_attrs(__TopXMLNS, _attrs, undefined, undefined), {sm_failed, Reason, Text, H, Xmlns}. decode_sm_failed_els(__TopXMLNS, __Opts, [], Text, Reason) -> {lists:reverse(Text), Reason}; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"text">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, [rfc6120:decode_error_text(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el) | Text], Reason); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"bad-request">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_bad_request(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"conflict">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_conflict(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"feature-not-implemented">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_feature_not_implemented(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"forbidden">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_forbidden(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"gone">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_gone(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"internal-server-error">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_internal_server_error(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"item-not-found">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_item_not_found(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"jid-malformed">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_jid_malformed(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"not-acceptable">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_not_acceptable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"not-allowed">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_not_allowed(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"not-authorized">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_not_authorized(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"policy-violation">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_policy_violation(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"recipient-unavailable">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_recipient_unavailable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"redirect">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_redirect(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"registration-required">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_registration_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"remote-server-not-found">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_remote_server_not_found(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"remote-server-timeout">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_remote_server_timeout(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"resource-constraint">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_resource_constraint(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"service-unavailable">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_service_unavailable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"subscription-required">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_subscription_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"undefined-condition">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_undefined_condition(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [{xmlel, <<"unexpected-request">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, rfc6120:decode_error_unexpected_request(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el)); _ -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sm_failed_els(__TopXMLNS, __Opts, [_ | _els], Text, Reason) -> decode_sm_failed_els(__TopXMLNS, __Opts, _els, Text, Reason). decode_sm_failed_attrs(__TopXMLNS, [{<<"h">>, _val} | _attrs], _H, Xmlns) -> decode_sm_failed_attrs(__TopXMLNS, _attrs, _val, Xmlns); decode_sm_failed_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], H, _Xmlns) -> decode_sm_failed_attrs(__TopXMLNS, _attrs, H, _val); decode_sm_failed_attrs(__TopXMLNS, [_ | _attrs], H, Xmlns) -> decode_sm_failed_attrs(__TopXMLNS, _attrs, H, Xmlns); decode_sm_failed_attrs(__TopXMLNS, [], H, Xmlns) -> {decode_sm_failed_attr_h(__TopXMLNS, H), decode_sm_failed_attr_xmlns(__TopXMLNS, Xmlns)}. encode_sm_failed({sm_failed, Reason, Text, H, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = lists:reverse('encode_sm_failed_$text'(Text, __NewTopXMLNS, 'encode_sm_failed_$reason'(Reason, __NewTopXMLNS, []))), _attrs = encode_sm_failed_attr_h(H, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"failed">>, _attrs, _els}. 'encode_sm_failed_$text'([], __TopXMLNS, _acc) -> _acc; 'encode_sm_failed_$text'([Text | _els], __TopXMLNS, _acc) -> 'encode_sm_failed_$text'(_els, __TopXMLNS, [rfc6120:encode_error_text(Text, __TopXMLNS) | _acc]). 'encode_sm_failed_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_sm_failed_$reason'('bad-request' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_bad_request(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'(conflict = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_conflict(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('feature-not-implemented' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_feature_not_implemented(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'(forbidden = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_forbidden(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'({gone, _} = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_gone(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('internal-server-error' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_internal_server_error(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('item-not-found' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_item_not_found(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('jid-malformed' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_jid_malformed(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('not-acceptable' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_not_acceptable(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('not-allowed' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_not_allowed(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('not-authorized' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_not_authorized(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('policy-violation' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_policy_violation(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('recipient-unavailable' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_recipient_unavailable(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'({redirect, _} = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_redirect(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('registration-required' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_registration_required(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('remote-server-not-found' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_remote_server_not_found(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('remote-server-timeout' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_remote_server_timeout(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('resource-constraint' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_resource_constraint(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('service-unavailable' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_service_unavailable(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('subscription-required' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_subscription_required(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('undefined-condition' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_undefined_condition(Reason, __TopXMLNS) | _acc]; 'encode_sm_failed_$reason'('unexpected-request' = Reason, __TopXMLNS, _acc) -> [rfc6120:encode_error_unexpected_request(Reason, __TopXMLNS) | _acc]. decode_sm_failed_attr_h(__TopXMLNS, undefined) -> undefined; decode_sm_failed_attr_h(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"h">>, <<"failed">>, __TopXMLNS}}); _res -> _res end. encode_sm_failed_attr_h(undefined, _acc) -> _acc; encode_sm_failed_attr_h(_val, _acc) -> [{<<"h">>, enc_int(_val)} | _acc]. decode_sm_failed_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sm_failed_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sm_a(__TopXMLNS, __Opts, {xmlel, <<"a">>, _attrs, _els}) -> {H, Xmlns} = decode_sm_a_attrs(__TopXMLNS, _attrs, undefined, undefined), {sm_a, H, Xmlns}. decode_sm_a_attrs(__TopXMLNS, [{<<"h">>, _val} | _attrs], _H, Xmlns) -> decode_sm_a_attrs(__TopXMLNS, _attrs, _val, Xmlns); decode_sm_a_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], H, _Xmlns) -> decode_sm_a_attrs(__TopXMLNS, _attrs, H, _val); decode_sm_a_attrs(__TopXMLNS, [_ | _attrs], H, Xmlns) -> decode_sm_a_attrs(__TopXMLNS, _attrs, H, Xmlns); decode_sm_a_attrs(__TopXMLNS, [], H, Xmlns) -> {decode_sm_a_attr_h(__TopXMLNS, H), decode_sm_a_attr_xmlns(__TopXMLNS, Xmlns)}. encode_sm_a({sm_a, H, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = [], _attrs = encode_sm_a_attr_h(H, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"a">>, _attrs, _els}. decode_sm_a_attr_h(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"h">>, <<"a">>, __TopXMLNS}}); decode_sm_a_attr_h(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"h">>, <<"a">>, __TopXMLNS}}); _res -> _res end. encode_sm_a_attr_h(_val, _acc) -> [{<<"h">>, enc_int(_val)} | _acc]. decode_sm_a_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sm_a_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sm_r(__TopXMLNS, __Opts, {xmlel, <<"r">>, _attrs, _els}) -> Xmlns = decode_sm_r_attrs(__TopXMLNS, _attrs, undefined), {sm_r, Xmlns}. decode_sm_r_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns) -> decode_sm_r_attrs(__TopXMLNS, _attrs, _val); decode_sm_r_attrs(__TopXMLNS, [_ | _attrs], Xmlns) -> decode_sm_r_attrs(__TopXMLNS, _attrs, Xmlns); decode_sm_r_attrs(__TopXMLNS, [], Xmlns) -> decode_sm_r_attr_xmlns(__TopXMLNS, Xmlns). encode_sm_r({sm_r, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"r">>, _attrs, _els}. decode_sm_r_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sm_r_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sm_resumed(__TopXMLNS, __Opts, {xmlel, <<"resumed">>, _attrs, _els}) -> {H, Xmlns, Previd} = decode_sm_resumed_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {sm_resumed, H, Previd, Xmlns}. decode_sm_resumed_attrs(__TopXMLNS, [{<<"h">>, _val} | _attrs], _H, Xmlns, Previd) -> decode_sm_resumed_attrs(__TopXMLNS, _attrs, _val, Xmlns, Previd); decode_sm_resumed_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], H, _Xmlns, Previd) -> decode_sm_resumed_attrs(__TopXMLNS, _attrs, H, _val, Previd); decode_sm_resumed_attrs(__TopXMLNS, [{<<"previd">>, _val} | _attrs], H, Xmlns, _Previd) -> decode_sm_resumed_attrs(__TopXMLNS, _attrs, H, Xmlns, _val); decode_sm_resumed_attrs(__TopXMLNS, [_ | _attrs], H, Xmlns, Previd) -> decode_sm_resumed_attrs(__TopXMLNS, _attrs, H, Xmlns, Previd); decode_sm_resumed_attrs(__TopXMLNS, [], H, Xmlns, Previd) -> {decode_sm_resumed_attr_h(__TopXMLNS, H), decode_sm_resumed_attr_xmlns(__TopXMLNS, Xmlns), decode_sm_resumed_attr_previd(__TopXMLNS, Previd)}. encode_sm_resumed({sm_resumed, H, Previd, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = [], _attrs = encode_sm_resumed_attr_previd(Previd, encode_sm_resumed_attr_h(H, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"resumed">>, _attrs, _els}. decode_sm_resumed_attr_h(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"h">>, <<"resumed">>, __TopXMLNS}}); decode_sm_resumed_attr_h(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"h">>, <<"resumed">>, __TopXMLNS}}); _res -> _res end. encode_sm_resumed_attr_h(_val, _acc) -> [{<<"h">>, enc_int(_val)} | _acc]. decode_sm_resumed_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sm_resumed_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sm_resumed_attr_previd(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"previd">>, <<"resumed">>, __TopXMLNS}}); decode_sm_resumed_attr_previd(__TopXMLNS, _val) -> _val. encode_sm_resumed_attr_previd(_val, _acc) -> [{<<"previd">>, _val} | _acc]. decode_sm_resume(__TopXMLNS, __Opts, {xmlel, <<"resume">>, _attrs, _els}) -> {H, Xmlns, Previd} = decode_sm_resume_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {sm_resume, H, Previd, Xmlns}. decode_sm_resume_attrs(__TopXMLNS, [{<<"h">>, _val} | _attrs], _H, Xmlns, Previd) -> decode_sm_resume_attrs(__TopXMLNS, _attrs, _val, Xmlns, Previd); decode_sm_resume_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], H, _Xmlns, Previd) -> decode_sm_resume_attrs(__TopXMLNS, _attrs, H, _val, Previd); decode_sm_resume_attrs(__TopXMLNS, [{<<"previd">>, _val} | _attrs], H, Xmlns, _Previd) -> decode_sm_resume_attrs(__TopXMLNS, _attrs, H, Xmlns, _val); decode_sm_resume_attrs(__TopXMLNS, [_ | _attrs], H, Xmlns, Previd) -> decode_sm_resume_attrs(__TopXMLNS, _attrs, H, Xmlns, Previd); decode_sm_resume_attrs(__TopXMLNS, [], H, Xmlns, Previd) -> {decode_sm_resume_attr_h(__TopXMLNS, H), decode_sm_resume_attr_xmlns(__TopXMLNS, Xmlns), decode_sm_resume_attr_previd(__TopXMLNS, Previd)}. encode_sm_resume({sm_resume, H, Previd, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = [], _attrs = encode_sm_resume_attr_previd(Previd, encode_sm_resume_attr_h(H, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"resume">>, _attrs, _els}. decode_sm_resume_attr_h(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"h">>, <<"resume">>, __TopXMLNS}}); decode_sm_resume_attr_h(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"h">>, <<"resume">>, __TopXMLNS}}); _res -> _res end. encode_sm_resume_attr_h(_val, _acc) -> [{<<"h">>, enc_int(_val)} | _acc]. decode_sm_resume_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sm_resume_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sm_resume_attr_previd(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"previd">>, <<"resume">>, __TopXMLNS}}); decode_sm_resume_attr_previd(__TopXMLNS, _val) -> _val. encode_sm_resume_attr_previd(_val, _acc) -> [{<<"previd">>, _val} | _acc]. decode_sm_enabled(__TopXMLNS, __Opts, {xmlel, <<"enabled">>, _attrs, _els}) -> {Id, Location, Xmlns, Max, Resume} = decode_sm_enabled_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {sm_enabled, Id, Location, Max, Resume, Xmlns}. decode_sm_enabled_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, Location, Xmlns, Max, Resume) -> decode_sm_enabled_attrs(__TopXMLNS, _attrs, _val, Location, Xmlns, Max, Resume); decode_sm_enabled_attrs(__TopXMLNS, [{<<"location">>, _val} | _attrs], Id, _Location, Xmlns, Max, Resume) -> decode_sm_enabled_attrs(__TopXMLNS, _attrs, Id, _val, Xmlns, Max, Resume); decode_sm_enabled_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Id, Location, _Xmlns, Max, Resume) -> decode_sm_enabled_attrs(__TopXMLNS, _attrs, Id, Location, _val, Max, Resume); decode_sm_enabled_attrs(__TopXMLNS, [{<<"max">>, _val} | _attrs], Id, Location, Xmlns, _Max, Resume) -> decode_sm_enabled_attrs(__TopXMLNS, _attrs, Id, Location, Xmlns, _val, Resume); decode_sm_enabled_attrs(__TopXMLNS, [{<<"resume">>, _val} | _attrs], Id, Location, Xmlns, Max, _Resume) -> decode_sm_enabled_attrs(__TopXMLNS, _attrs, Id, Location, Xmlns, Max, _val); decode_sm_enabled_attrs(__TopXMLNS, [_ | _attrs], Id, Location, Xmlns, Max, Resume) -> decode_sm_enabled_attrs(__TopXMLNS, _attrs, Id, Location, Xmlns, Max, Resume); decode_sm_enabled_attrs(__TopXMLNS, [], Id, Location, Xmlns, Max, Resume) -> {decode_sm_enabled_attr_id(__TopXMLNS, Id), decode_sm_enabled_attr_location(__TopXMLNS, Location), decode_sm_enabled_attr_xmlns(__TopXMLNS, Xmlns), decode_sm_enabled_attr_max(__TopXMLNS, Max), decode_sm_enabled_attr_resume(__TopXMLNS, Resume)}. encode_sm_enabled({sm_enabled, Id, Location, Max, Resume, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = [], _attrs = encode_sm_enabled_attr_resume(Resume, encode_sm_enabled_attr_max(Max, encode_sm_enabled_attr_location(Location, encode_sm_enabled_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"enabled">>, _attrs, _els}. decode_sm_enabled_attr_id(__TopXMLNS, undefined) -> <<>>; decode_sm_enabled_attr_id(__TopXMLNS, _val) -> _val. encode_sm_enabled_attr_id(<<>>, _acc) -> _acc; encode_sm_enabled_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_sm_enabled_attr_location(__TopXMLNS, undefined) -> <<>>; decode_sm_enabled_attr_location(__TopXMLNS, _val) -> _val. encode_sm_enabled_attr_location(<<>>, _acc) -> _acc; encode_sm_enabled_attr_location(_val, _acc) -> [{<<"location">>, _val} | _acc]. decode_sm_enabled_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sm_enabled_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sm_enabled_attr_max(__TopXMLNS, undefined) -> undefined; decode_sm_enabled_attr_max(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"max">>, <<"enabled">>, __TopXMLNS}}); _res -> _res end. encode_sm_enabled_attr_max(undefined, _acc) -> _acc; encode_sm_enabled_attr_max(_val, _acc) -> [{<<"max">>, enc_int(_val)} | _acc]. decode_sm_enabled_attr_resume(__TopXMLNS, undefined) -> false; decode_sm_enabled_attr_resume(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"resume">>, <<"enabled">>, __TopXMLNS}}); _res -> _res end. encode_sm_enabled_attr_resume(false, _acc) -> _acc; encode_sm_enabled_attr_resume(_val, _acc) -> [{<<"resume">>, enc_bool(_val)} | _acc]. decode_sm_enable(__TopXMLNS, __Opts, {xmlel, <<"enable">>, _attrs, _els}) -> {Max, Xmlns, Resume} = decode_sm_enable_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {sm_enable, Max, Resume, Xmlns}. decode_sm_enable_attrs(__TopXMLNS, [{<<"max">>, _val} | _attrs], _Max, Xmlns, Resume) -> decode_sm_enable_attrs(__TopXMLNS, _attrs, _val, Xmlns, Resume); decode_sm_enable_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Max, _Xmlns, Resume) -> decode_sm_enable_attrs(__TopXMLNS, _attrs, Max, _val, Resume); decode_sm_enable_attrs(__TopXMLNS, [{<<"resume">>, _val} | _attrs], Max, Xmlns, _Resume) -> decode_sm_enable_attrs(__TopXMLNS, _attrs, Max, Xmlns, _val); decode_sm_enable_attrs(__TopXMLNS, [_ | _attrs], Max, Xmlns, Resume) -> decode_sm_enable_attrs(__TopXMLNS, _attrs, Max, Xmlns, Resume); decode_sm_enable_attrs(__TopXMLNS, [], Max, Xmlns, Resume) -> {decode_sm_enable_attr_max(__TopXMLNS, Max), decode_sm_enable_attr_xmlns(__TopXMLNS, Xmlns), decode_sm_enable_attr_resume(__TopXMLNS, Resume)}. encode_sm_enable({sm_enable, Max, Resume, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = [], _attrs = encode_sm_enable_attr_resume(Resume, encode_sm_enable_attr_max(Max, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"enable">>, _attrs, _els}. decode_sm_enable_attr_max(__TopXMLNS, undefined) -> undefined; decode_sm_enable_attr_max(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"max">>, <<"enable">>, __TopXMLNS}}); _res -> _res end. encode_sm_enable_attr_max(undefined, _acc) -> _acc; encode_sm_enable_attr_max(_val, _acc) -> [{<<"max">>, enc_int(_val)} | _acc]. decode_sm_enable_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sm_enable_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sm_enable_attr_resume(__TopXMLNS, undefined) -> false; decode_sm_enable_attr_resume(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"resume">>, <<"enable">>, __TopXMLNS}}); _res -> _res end. encode_sm_enable_attr_resume(false, _acc) -> _acc; encode_sm_enable_attr_resume(_val, _acc) -> [{<<"resume">>, enc_bool(_val)} | _acc]. decode_feature_sm(__TopXMLNS, __Opts, {xmlel, <<"sm">>, _attrs, _els}) -> Xmlns = decode_feature_sm_attrs(__TopXMLNS, _attrs, undefined), {feature_sm, Xmlns}. decode_feature_sm_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns) -> decode_feature_sm_attrs(__TopXMLNS, _attrs, _val); decode_feature_sm_attrs(__TopXMLNS, [_ | _attrs], Xmlns) -> decode_feature_sm_attrs(__TopXMLNS, _attrs, Xmlns); decode_feature_sm_attrs(__TopXMLNS, [], Xmlns) -> decode_feature_sm_attr_xmlns(__TopXMLNS, Xmlns). encode_feature_sm({feature_sm, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sm:2">>, <<"urn:xmpp:sm:3">>], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"sm">>, _attrs, _els}. decode_feature_sm_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_feature_sm_attr_xmlns(__TopXMLNS, _val) -> _val. xmpp-1.4.4/src/xep0033.erl0000644000232200023220000001644213610066730015460 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0033). -compile(export_all). do_decode(<<"addresses">>, <<"http://jabber.org/protocol/address">>, El, Opts) -> decode_addresses(<<"http://jabber.org/protocol/address">>, Opts, El); do_decode(<<"address">>, <<"http://jabber.org/protocol/address">>, El, Opts) -> decode_address(<<"http://jabber.org/protocol/address">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"addresses">>, <<"http://jabber.org/protocol/address">>}, {<<"address">>, <<"http://jabber.org/protocol/address">>}]. do_encode({address, _, _, _, _, _} = Address, TopXMLNS) -> encode_address(Address, TopXMLNS); do_encode({addresses, _} = Addresses, TopXMLNS) -> encode_addresses(Addresses, TopXMLNS). do_get_name({address, _, _, _, _, _}) -> <<"address">>; do_get_name({addresses, _}) -> <<"addresses">>. do_get_ns({address, _, _, _, _, _}) -> <<"http://jabber.org/protocol/address">>; do_get_ns({addresses, _}) -> <<"http://jabber.org/protocol/address">>. pp(address, 5) -> [type, jid, desc, node, delivered]; pp(addresses, 1) -> [list]; pp(_, _) -> no. records() -> [{address, 5}, {addresses, 1}]. dec_bool(<<"false">>) -> false; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"1">>) -> true. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_bool(false) -> <<"false">>; enc_bool(true) -> <<"true">>. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). decode_addresses(__TopXMLNS, __Opts, {xmlel, <<"addresses">>, _attrs, _els}) -> List = decode_addresses_els(__TopXMLNS, __Opts, _els, []), {addresses, List}. decode_addresses_els(__TopXMLNS, __Opts, [], List) -> lists:reverse(List); decode_addresses_els(__TopXMLNS, __Opts, [{xmlel, <<"address">>, _attrs, _} = _el | _els], List) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/address">> -> decode_addresses_els(__TopXMLNS, __Opts, _els, [decode_address(<<"http://jabber.org/protocol/address">>, __Opts, _el) | List]); _ -> decode_addresses_els(__TopXMLNS, __Opts, _els, List) end; decode_addresses_els(__TopXMLNS, __Opts, [_ | _els], List) -> decode_addresses_els(__TopXMLNS, __Opts, _els, List). encode_addresses({addresses, List}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/address">>, [], __TopXMLNS), _els = lists:reverse('encode_addresses_$list'(List, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"addresses">>, _attrs, _els}. 'encode_addresses_$list'([], __TopXMLNS, _acc) -> _acc; 'encode_addresses_$list'([List | _els], __TopXMLNS, _acc) -> 'encode_addresses_$list'(_els, __TopXMLNS, [encode_address(List, __TopXMLNS) | _acc]). decode_address(__TopXMLNS, __Opts, {xmlel, <<"address">>, _attrs, _els}) -> {Type, Jid, Desc, Node, Delivered} = decode_address_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {address, Type, Jid, Desc, Node, Delivered}. decode_address_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], _Type, Jid, Desc, Node, Delivered) -> decode_address_attrs(__TopXMLNS, _attrs, _val, Jid, Desc, Node, Delivered); decode_address_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Type, _Jid, Desc, Node, Delivered) -> decode_address_attrs(__TopXMLNS, _attrs, Type, _val, Desc, Node, Delivered); decode_address_attrs(__TopXMLNS, [{<<"desc">>, _val} | _attrs], Type, Jid, _Desc, Node, Delivered) -> decode_address_attrs(__TopXMLNS, _attrs, Type, Jid, _val, Node, Delivered); decode_address_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Type, Jid, Desc, _Node, Delivered) -> decode_address_attrs(__TopXMLNS, _attrs, Type, Jid, Desc, _val, Delivered); decode_address_attrs(__TopXMLNS, [{<<"delivered">>, _val} | _attrs], Type, Jid, Desc, Node, _Delivered) -> decode_address_attrs(__TopXMLNS, _attrs, Type, Jid, Desc, Node, _val); decode_address_attrs(__TopXMLNS, [_ | _attrs], Type, Jid, Desc, Node, Delivered) -> decode_address_attrs(__TopXMLNS, _attrs, Type, Jid, Desc, Node, Delivered); decode_address_attrs(__TopXMLNS, [], Type, Jid, Desc, Node, Delivered) -> {decode_address_attr_type(__TopXMLNS, Type), decode_address_attr_jid(__TopXMLNS, Jid), decode_address_attr_desc(__TopXMLNS, Desc), decode_address_attr_node(__TopXMLNS, Node), decode_address_attr_delivered(__TopXMLNS, Delivered)}. encode_address({address, Type, Jid, Desc, Node, Delivered}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/address">>, [], __TopXMLNS), _els = [], _attrs = encode_address_attr_delivered(Delivered, encode_address_attr_node(Node, encode_address_attr_desc(Desc, encode_address_attr_jid(Jid, encode_address_attr_type(Type, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"address">>, _attrs, _els}. decode_address_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"address">>, __TopXMLNS}}); decode_address_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [bcc, cc, noreply, ofrom, replyroom, replyto, to]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"address">>, __TopXMLNS}}); _res -> _res end. encode_address_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_address_attr_jid(__TopXMLNS, undefined) -> undefined; decode_address_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"address">>, __TopXMLNS}}); _res -> _res end. encode_address_attr_jid(undefined, _acc) -> _acc; encode_address_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_address_attr_desc(__TopXMLNS, undefined) -> <<>>; decode_address_attr_desc(__TopXMLNS, _val) -> _val. encode_address_attr_desc(<<>>, _acc) -> _acc; encode_address_attr_desc(_val, _acc) -> [{<<"desc">>, _val} | _acc]. decode_address_attr_node(__TopXMLNS, undefined) -> <<>>; decode_address_attr_node(__TopXMLNS, _val) -> _val. encode_address_attr_node(<<>>, _acc) -> _acc; encode_address_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_address_attr_delivered(__TopXMLNS, undefined) -> undefined; decode_address_attr_delivered(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"delivered">>, <<"address">>, __TopXMLNS}}); _res -> _res end. encode_address_attr_delivered(undefined, _acc) -> _acc; encode_address_attr_delivered(_val, _acc) -> [{<<"delivered">>, enc_bool(_val)} | _acc]. xmpp-1.4.4/src/xep0065.erl0000644000232200023220000003437713610066730015474 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0065). -compile(export_all). do_decode(<<"query">>, <<"http://jabber.org/protocol/bytestreams">>, El, Opts) -> decode_bytestreams(<<"http://jabber.org/protocol/bytestreams">>, Opts, El); do_decode(<<"activate">>, <<"http://jabber.org/protocol/bytestreams">>, El, Opts) -> decode_bytestreams_activate(<<"http://jabber.org/protocol/bytestreams">>, Opts, El); do_decode(<<"streamhost-used">>, <<"http://jabber.org/protocol/bytestreams">>, El, Opts) -> decode_bytestreams_streamhost_used(<<"http://jabber.org/protocol/bytestreams">>, Opts, El); do_decode(<<"streamhost">>, <<"http://jabber.org/protocol/bytestreams">>, El, Opts) -> decode_bytestreams_streamhost(<<"http://jabber.org/protocol/bytestreams">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"http://jabber.org/protocol/bytestreams">>}, {<<"activate">>, <<"http://jabber.org/protocol/bytestreams">>}, {<<"streamhost-used">>, <<"http://jabber.org/protocol/bytestreams">>}, {<<"streamhost">>, <<"http://jabber.org/protocol/bytestreams">>}]. do_encode({streamhost, _, _, _} = Streamhost, TopXMLNS) -> encode_bytestreams_streamhost(Streamhost, TopXMLNS); do_encode({bytestreams, _, _, _, _, _, _} = Query, TopXMLNS) -> encode_bytestreams(Query, TopXMLNS). do_get_name({bytestreams, _, _, _, _, _, _}) -> <<"query">>; do_get_name({streamhost, _, _, _}) -> <<"streamhost">>. do_get_ns({bytestreams, _, _, _, _, _, _}) -> <<"http://jabber.org/protocol/bytestreams">>; do_get_ns({streamhost, _, _, _}) -> <<"http://jabber.org/protocol/bytestreams">>. pp(streamhost, 3) -> [jid, host, port]; pp(bytestreams, 6) -> [hosts, used, activate, dstaddr, mode, sid]; pp(_, _) -> no. records() -> [{streamhost, 3}, {bytestreams, 6}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). decode_bytestreams(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Hosts, Used, Activate} = decode_bytestreams_els(__TopXMLNS, __Opts, _els, [], undefined, undefined), {Dstaddr, Sid, Mode} = decode_bytestreams_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {bytestreams, Hosts, Used, Activate, Dstaddr, Mode, Sid}. decode_bytestreams_els(__TopXMLNS, __Opts, [], Hosts, Used, Activate) -> {lists:reverse(Hosts), Used, Activate}; decode_bytestreams_els(__TopXMLNS, __Opts, [{xmlel, <<"streamhost">>, _attrs, _} = _el | _els], Hosts, Used, Activate) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/bytestreams">> -> decode_bytestreams_els(__TopXMLNS, __Opts, _els, [decode_bytestreams_streamhost(<<"http://jabber.org/protocol/bytestreams">>, __Opts, _el) | Hosts], Used, Activate); _ -> decode_bytestreams_els(__TopXMLNS, __Opts, _els, Hosts, Used, Activate) end; decode_bytestreams_els(__TopXMLNS, __Opts, [{xmlel, <<"streamhost-used">>, _attrs, _} = _el | _els], Hosts, Used, Activate) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/bytestreams">> -> decode_bytestreams_els(__TopXMLNS, __Opts, _els, Hosts, decode_bytestreams_streamhost_used(<<"http://jabber.org/protocol/bytestreams">>, __Opts, _el), Activate); _ -> decode_bytestreams_els(__TopXMLNS, __Opts, _els, Hosts, Used, Activate) end; decode_bytestreams_els(__TopXMLNS, __Opts, [{xmlel, <<"activate">>, _attrs, _} = _el | _els], Hosts, Used, Activate) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/bytestreams">> -> decode_bytestreams_els(__TopXMLNS, __Opts, _els, Hosts, Used, decode_bytestreams_activate(<<"http://jabber.org/protocol/bytestreams">>, __Opts, _el)); _ -> decode_bytestreams_els(__TopXMLNS, __Opts, _els, Hosts, Used, Activate) end; decode_bytestreams_els(__TopXMLNS, __Opts, [_ | _els], Hosts, Used, Activate) -> decode_bytestreams_els(__TopXMLNS, __Opts, _els, Hosts, Used, Activate). decode_bytestreams_attrs(__TopXMLNS, [{<<"dstaddr">>, _val} | _attrs], _Dstaddr, Sid, Mode) -> decode_bytestreams_attrs(__TopXMLNS, _attrs, _val, Sid, Mode); decode_bytestreams_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], Dstaddr, _Sid, Mode) -> decode_bytestreams_attrs(__TopXMLNS, _attrs, Dstaddr, _val, Mode); decode_bytestreams_attrs(__TopXMLNS, [{<<"mode">>, _val} | _attrs], Dstaddr, Sid, _Mode) -> decode_bytestreams_attrs(__TopXMLNS, _attrs, Dstaddr, Sid, _val); decode_bytestreams_attrs(__TopXMLNS, [_ | _attrs], Dstaddr, Sid, Mode) -> decode_bytestreams_attrs(__TopXMLNS, _attrs, Dstaddr, Sid, Mode); decode_bytestreams_attrs(__TopXMLNS, [], Dstaddr, Sid, Mode) -> {decode_bytestreams_attr_dstaddr(__TopXMLNS, Dstaddr), decode_bytestreams_attr_sid(__TopXMLNS, Sid), decode_bytestreams_attr_mode(__TopXMLNS, Mode)}. encode_bytestreams({bytestreams, Hosts, Used, Activate, Dstaddr, Mode, Sid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/bytestreams">>, [], __TopXMLNS), _els = lists:reverse('encode_bytestreams_$hosts'(Hosts, __NewTopXMLNS, 'encode_bytestreams_$used'(Used, __NewTopXMLNS, 'encode_bytestreams_$activate'(Activate, __NewTopXMLNS, [])))), _attrs = encode_bytestreams_attr_mode(Mode, encode_bytestreams_attr_sid(Sid, encode_bytestreams_attr_dstaddr(Dstaddr, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"query">>, _attrs, _els}. 'encode_bytestreams_$hosts'([], __TopXMLNS, _acc) -> _acc; 'encode_bytestreams_$hosts'([Hosts | _els], __TopXMLNS, _acc) -> 'encode_bytestreams_$hosts'(_els, __TopXMLNS, [encode_bytestreams_streamhost(Hosts, __TopXMLNS) | _acc]). 'encode_bytestreams_$used'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_bytestreams_$used'(Used, __TopXMLNS, _acc) -> [encode_bytestreams_streamhost_used(Used, __TopXMLNS) | _acc]. 'encode_bytestreams_$activate'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_bytestreams_$activate'(Activate, __TopXMLNS, _acc) -> [encode_bytestreams_activate(Activate, __TopXMLNS) | _acc]. decode_bytestreams_attr_dstaddr(__TopXMLNS, undefined) -> <<>>; decode_bytestreams_attr_dstaddr(__TopXMLNS, _val) -> _val. encode_bytestreams_attr_dstaddr(<<>>, _acc) -> _acc; encode_bytestreams_attr_dstaddr(_val, _acc) -> [{<<"dstaddr">>, _val} | _acc]. decode_bytestreams_attr_sid(__TopXMLNS, undefined) -> <<>>; decode_bytestreams_attr_sid(__TopXMLNS, _val) -> _val. encode_bytestreams_attr_sid(<<>>, _acc) -> _acc; encode_bytestreams_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. decode_bytestreams_attr_mode(__TopXMLNS, undefined) -> tcp; decode_bytestreams_attr_mode(__TopXMLNS, _val) -> case catch dec_enum(_val, [tcp, udp]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"mode">>, <<"query">>, __TopXMLNS}}); _res -> _res end. encode_bytestreams_attr_mode(tcp, _acc) -> _acc; encode_bytestreams_attr_mode(_val, _acc) -> [{<<"mode">>, enc_enum(_val)} | _acc]. decode_bytestreams_activate(__TopXMLNS, __Opts, {xmlel, <<"activate">>, _attrs, _els}) -> Cdata = decode_bytestreams_activate_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_bytestreams_activate_els(__TopXMLNS, __Opts, [], Cdata) -> decode_bytestreams_activate_cdata(__TopXMLNS, Cdata); decode_bytestreams_activate_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_bytestreams_activate_els(__TopXMLNS, __Opts, _els, <>); decode_bytestreams_activate_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_bytestreams_activate_els(__TopXMLNS, __Opts, _els, Cdata). encode_bytestreams_activate(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/bytestreams">>, [], __TopXMLNS), _els = encode_bytestreams_activate_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"activate">>, _attrs, _els}. decode_bytestreams_activate_cdata(__TopXMLNS, <<>>) -> undefined; decode_bytestreams_activate_cdata(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"activate">>, __TopXMLNS}}); _res -> _res end. encode_bytestreams_activate_cdata(undefined, _acc) -> _acc; encode_bytestreams_activate_cdata(_val, _acc) -> [{xmlcdata, jid:encode(_val)} | _acc]. decode_bytestreams_streamhost_used(__TopXMLNS, __Opts, {xmlel, <<"streamhost-used">>, _attrs, _els}) -> Jid = decode_bytestreams_streamhost_used_attrs(__TopXMLNS, _attrs, undefined), Jid. decode_bytestreams_streamhost_used_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid) -> decode_bytestreams_streamhost_used_attrs(__TopXMLNS, _attrs, _val); decode_bytestreams_streamhost_used_attrs(__TopXMLNS, [_ | _attrs], Jid) -> decode_bytestreams_streamhost_used_attrs(__TopXMLNS, _attrs, Jid); decode_bytestreams_streamhost_used_attrs(__TopXMLNS, [], Jid) -> decode_bytestreams_streamhost_used_attr_jid(__TopXMLNS, Jid). encode_bytestreams_streamhost_used(Jid, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/bytestreams">>, [], __TopXMLNS), _els = [], _attrs = encode_bytestreams_streamhost_used_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"streamhost-used">>, _attrs, _els}. decode_bytestreams_streamhost_used_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"streamhost-used">>, __TopXMLNS}}); decode_bytestreams_streamhost_used_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"streamhost-used">>, __TopXMLNS}}); _res -> _res end. encode_bytestreams_streamhost_used_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_bytestreams_streamhost(__TopXMLNS, __Opts, {xmlel, <<"streamhost">>, _attrs, _els}) -> {Jid, Host, Port} = decode_bytestreams_streamhost_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {streamhost, Jid, Host, Port}. decode_bytestreams_streamhost_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Host, Port) -> decode_bytestreams_streamhost_attrs(__TopXMLNS, _attrs, _val, Host, Port); decode_bytestreams_streamhost_attrs(__TopXMLNS, [{<<"host">>, _val} | _attrs], Jid, _Host, Port) -> decode_bytestreams_streamhost_attrs(__TopXMLNS, _attrs, Jid, _val, Port); decode_bytestreams_streamhost_attrs(__TopXMLNS, [{<<"port">>, _val} | _attrs], Jid, Host, _Port) -> decode_bytestreams_streamhost_attrs(__TopXMLNS, _attrs, Jid, Host, _val); decode_bytestreams_streamhost_attrs(__TopXMLNS, [_ | _attrs], Jid, Host, Port) -> decode_bytestreams_streamhost_attrs(__TopXMLNS, _attrs, Jid, Host, Port); decode_bytestreams_streamhost_attrs(__TopXMLNS, [], Jid, Host, Port) -> {decode_bytestreams_streamhost_attr_jid(__TopXMLNS, Jid), decode_bytestreams_streamhost_attr_host(__TopXMLNS, Host), decode_bytestreams_streamhost_attr_port(__TopXMLNS, Port)}. encode_bytestreams_streamhost({streamhost, Jid, Host, Port}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/bytestreams">>, [], __TopXMLNS), _els = [], _attrs = encode_bytestreams_streamhost_attr_port(Port, encode_bytestreams_streamhost_attr_host(Host, encode_bytestreams_streamhost_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"streamhost">>, _attrs, _els}. decode_bytestreams_streamhost_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"streamhost">>, __TopXMLNS}}); decode_bytestreams_streamhost_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"streamhost">>, __TopXMLNS}}); _res -> _res end. encode_bytestreams_streamhost_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_bytestreams_streamhost_attr_host(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"host">>, <<"streamhost">>, __TopXMLNS}}); decode_bytestreams_streamhost_attr_host(__TopXMLNS, _val) -> _val. encode_bytestreams_streamhost_attr_host(_val, _acc) -> [{<<"host">>, _val} | _acc]. decode_bytestreams_streamhost_attr_port(__TopXMLNS, undefined) -> 1080; decode_bytestreams_streamhost_attr_port(__TopXMLNS, _val) -> case catch dec_int(_val, 0, 65535) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"port">>, <<"streamhost">>, __TopXMLNS}}); _res -> _res end. encode_bytestreams_streamhost_attr_port(1080, _acc) -> _acc; encode_bytestreams_streamhost_attr_port(_val, _acc) -> [{<<"port">>, enc_int(_val)} | _acc]. xmpp-1.4.4/src/pubsub_publish_options.erl0000644000232200023220000002240713610066730021155 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_publish_options.xdata %% Form type: http://jabber.org/protocol/pubsub#publish-options %% Document: XEP-0060 -module(pubsub_publish_options). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("pubsub_publish_options.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [persist_items | access_model]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/pubsub#publish-opt" "ions">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {persist_items, Val} -> [encode_persist_items(Val, Lang, lists:member(persist_items, Required))]; {access_model, Val} -> [encode_access_model(Val, default, Lang, lists:member(access_model, Required))]; {access_model, Val, Opts} -> [encode_access_model(Val, Opts, Lang, lists:member(access_model, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/pubsub#publish-opt" "ions">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"pubsub#persist_items">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#persist_items">>, Required), [{persist_items, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#persist_items">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#persist_items">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#persist_items">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#persist_items">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#persist_items">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#access_model">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [authorize, open, presence, roster, whitelist]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#access_model">>, Required), [{access_model, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#access_model">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#access_model">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#access_model">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#access_model">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#access_model">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_persist_items(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_persist_items(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#persist_items">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Persist items to storage"))}. -spec encode_access_model(access_model() | undefined, default | options(access_model()), binary(), boolean()) -> xdata_field(). encode_access_model(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Access model of authorize")), value = <<"authorize">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Access model of open")), value = <<"open">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Access model of presence")), value = <<"presence">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Access model of roster")), value = <<"roster">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Access model of whitelist")), value = <<"whitelist">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#access_model">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Specify the access model"))}. xmpp-1.4.4/src/xmpp_config.erl0000644000232200023220000000251513610066730016663 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_config). %% API -export([debug/1, fqdn/1]). %%%=================================================================== %%% API %%%=================================================================== -spec fqdn(any()) -> {ok, [binary()]}. fqdn(_) -> {ok, []}. -spec debug(any()) -> {ok, boolean()}. debug(_) -> {ok, false}. %%%=================================================================== %%% Internal functions %%%=================================================================== xmpp-1.4.4/src/http_upload.erl0000644000232200023220000001563213610066730016701 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: http_upload.xdata %% Form type: urn:xmpp:http:upload:0, urn:xmpp:http:upload, eu:siacs:conversations:http:upload %% Document: XEP-0363 -module(http_upload). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/2, encode/3, encode/4]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("http_upload.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), binary(), ['max-file-size']) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"urn:xmpp:http:upload:0">>, <<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg, XMLNS) -> encode(Cfg, XMLNS, <<"en">>, []). encode(Cfg, XMLNS, Lang) -> encode(Cfg, XMLNS, Lang, []). encode(List, XMLNS, Lang, Required) -> Fs = [case Opt of {'max-file-size', Val} -> ['encode_max-file-size'(Val, Lang, lists:member('max-file-size', Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [XMLNS]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"max-file-size">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"max-file-size">>, Required), [{'max-file-size', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"max-file-size">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"max-file-size">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"max-file-size">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"max-file-size">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"max-file-size">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec 'encode_max-file-size'(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). 'encode_max-file-size'(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"max-file-size">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Maximum file size"))}. xmpp-1.4.4/src/flex_offline.erl0000644000232200023220000001552213610066730017014 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: flex_offline.xdata %% Form type: http://jabber.org/protocol/offline %% Document: XEP-0013 -module(flex_offline). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("flex_offline.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [number_of_messages]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/offline">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {number_of_messages, Val} -> [encode_number_of_messages(Val, Lang, lists:member(number_of_messages, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/offline">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"number_of_messages">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"number_of_messages">>, Required), [{number_of_messages, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"number_of_messages">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"number_of_messages">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"number_of_messages">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"number_of_messages">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"number_of_messages">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_number_of_messages(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_number_of_messages(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"number_of_messages">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Number of Offline Messages"))}. xmpp-1.4.4/src/xmpp_sasl_oauth.erl0000644000232200023220000000627313610066730017565 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_sasl_oauth). -behaviour(xmpp_sasl). -author('alexey@process-one.net'). -export([mech_new/4, mech_step/2, format_error/1]). %% For tests -export([parse/1]). -record(state, {host, check_password}). -type error_reason() :: parser_failed | not_authorized. -export_type([error_reason/0]). -spec format_error(error_reason()) -> {atom(), binary()}. format_error(parser_failed) -> {'bad-protocol', <<"Response decoding failed">>}; format_error(not_authorized) -> {'not-authorized', <<"Invalid token">>}. mech_new(Host, _GetPassword, CheckPassword, _CheckPasswordDigest) -> #state{host = Host, check_password = CheckPassword}. mech_step(State, ClientIn) -> case prepare(ClientIn) of [AuthzId, User, Token] -> case (State#state.check_password)(User, AuthzId, Token) of {true, AuthModule} -> {ok, [{username, User}, {authzid, AuthzId}, {auth_module, AuthModule}]}; _ -> {error, not_authorized, User} end; _ -> {error, parser_failed} end. prepare(ClientIn) -> case parse(ClientIn) of [<<"">>, UserMaybeDomain, Token] -> case parse_domain(UserMaybeDomain) of %% login@domainpwd [User, _Domain] -> [User, User, Token]; %% loginpwd [User] -> [User, User, Token] end; %% login@domainloginpwd [AuthzId, User, Token] -> case parse_domain(AuthzId) of %% login@domainloginpwd [AuthzUser, _Domain] -> [AuthzUser, User, Token]; %% loginloginpwd [AuthzUser] -> [AuthzUser, User, Token] end; _ -> error end. parse(S) -> parse1(binary_to_list(S), "", []). parse1([0 | Cs], S, T) -> parse1(Cs, "", [list_to_binary(lists:reverse(S)) | T]); parse1([C | Cs], S, T) -> parse1(Cs, [C | S], T); %parse1([], [], T) -> % lists:reverse(T); parse1([], S, T) -> lists:reverse([list_to_binary(lists:reverse(S)) | T]). parse_domain(S) -> parse_domain1(binary_to_list(S), "", []). parse_domain1([$@ | Cs], S, T) -> parse_domain1(Cs, "", [list_to_binary(lists:reverse(S)) | T]); parse_domain1([C | Cs], S, T) -> parse_domain1(Cs, [C | S], T); parse_domain1([], S, T) -> lists:reverse([list_to_binary(lists:reverse(S)) | T]). xmpp-1.4.4/src/muc_roomconfig.erl0000644000232200023220000016330613610066730017366 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_roomconfig.xdata %% Form type: http://jabber.org/protocol/muc#roomconfig %% Document: XEP-0045 -module(muc_roomconfig). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("muc_roomconfig.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [maxhistoryfetch | allowpm | allow_private_messages | allow_private_messages_from_visitors | allow_visitor_status | allow_visitor_nickchange | allow_voice_requests | allow_subscription | voice_request_min_interval | captcha_protected | captcha_whitelist | allow_query_users | allowinvites | changesubject | enablelogging | getmemberlist | lang | pubsub | maxusers | membersonly | moderatedroom | members_by_default | passwordprotectedroom | persistentroom | presencebroadcast | publicroom | public_list | roomadmins | roomdesc | roomname | roomowners | roomsecret | whois | mam]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/muc#roomconfig">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {maxhistoryfetch, Val} -> [encode_maxhistoryfetch(Val, Lang, lists:member(maxhistoryfetch, Required))]; {allowpm, Val} -> [encode_allowpm(Val, default, Lang, lists:member(allowpm, Required))]; {allowpm, Val, Opts} -> [encode_allowpm(Val, Opts, Lang, lists:member(allowpm, Required))]; {allow_private_messages, Val} -> [encode_allow_private_messages(Val, Lang, lists:member(allow_private_messages, Required))]; {allow_private_messages_from_visitors, Val} -> [encode_allow_private_messages_from_visitors(Val, default, Lang, lists:member(allow_private_messages_from_visitors, Required))]; {allow_private_messages_from_visitors, Val, Opts} -> [encode_allow_private_messages_from_visitors(Val, Opts, Lang, lists:member(allow_private_messages_from_visitors, Required))]; {allow_visitor_status, Val} -> [encode_allow_visitor_status(Val, Lang, lists:member(allow_visitor_status, Required))]; {allow_visitor_nickchange, Val} -> [encode_allow_visitor_nickchange(Val, Lang, lists:member(allow_visitor_nickchange, Required))]; {allow_voice_requests, Val} -> [encode_allow_voice_requests(Val, Lang, lists:member(allow_voice_requests, Required))]; {allow_subscription, Val} -> [encode_allow_subscription(Val, Lang, lists:member(allow_subscription, Required))]; {voice_request_min_interval, Val} -> [encode_voice_request_min_interval(Val, Lang, lists:member(voice_request_min_interval, Required))]; {captcha_protected, Val} -> [encode_captcha_protected(Val, Lang, lists:member(captcha_protected, Required))]; {captcha_whitelist, Val} -> [encode_captcha_whitelist(Val, Lang, lists:member(captcha_whitelist, Required))]; {allow_query_users, Val} -> [encode_allow_query_users(Val, Lang, lists:member(allow_query_users, Required))]; {allowinvites, Val} -> [encode_allowinvites(Val, Lang, lists:member(allowinvites, Required))]; {changesubject, Val} -> [encode_changesubject(Val, Lang, lists:member(changesubject, Required))]; {enablelogging, Val} -> [encode_enablelogging(Val, Lang, lists:member(enablelogging, Required))]; {getmemberlist, Val} -> [encode_getmemberlist(Val, default, Lang, lists:member(getmemberlist, Required))]; {getmemberlist, Val, Opts} -> [encode_getmemberlist(Val, Opts, Lang, lists:member(getmemberlist, Required))]; {lang, Val} -> [encode_lang(Val, Lang, lists:member(lang, Required))]; {pubsub, Val} -> [encode_pubsub(Val, Lang, lists:member(pubsub, Required))]; {maxusers, Val} -> [encode_maxusers(Val, default, Lang, lists:member(maxusers, Required))]; {maxusers, Val, Opts} -> [encode_maxusers(Val, Opts, Lang, lists:member(maxusers, Required))]; {membersonly, Val} -> [encode_membersonly(Val, Lang, lists:member(membersonly, Required))]; {moderatedroom, Val} -> [encode_moderatedroom(Val, Lang, lists:member(moderatedroom, Required))]; {members_by_default, Val} -> [encode_members_by_default(Val, Lang, lists:member(members_by_default, Required))]; {passwordprotectedroom, Val} -> [encode_passwordprotectedroom(Val, Lang, lists:member(passwordprotectedroom, Required))]; {persistentroom, Val} -> [encode_persistentroom(Val, Lang, lists:member(persistentroom, Required))]; {presencebroadcast, Val} -> [encode_presencebroadcast(Val, default, Lang, lists:member(presencebroadcast, Required))]; {presencebroadcast, Val, Opts} -> [encode_presencebroadcast(Val, Opts, Lang, lists:member(presencebroadcast, Required))]; {publicroom, Val} -> [encode_publicroom(Val, Lang, lists:member(publicroom, Required))]; {public_list, Val} -> [encode_public_list(Val, Lang, lists:member(public_list, Required))]; {roomadmins, Val} -> [encode_roomadmins(Val, Lang, lists:member(roomadmins, Required))]; {roomdesc, Val} -> [encode_roomdesc(Val, Lang, lists:member(roomdesc, Required))]; {roomname, Val} -> [encode_roomname(Val, Lang, lists:member(roomname, Required))]; {roomowners, Val} -> [encode_roomowners(Val, Lang, lists:member(roomowners, Required))]; {roomsecret, Val} -> [encode_roomsecret(Val, Lang, lists:member(roomsecret, Required))]; {whois, Val} -> [encode_whois(Val, default, Lang, lists:member(whois, Required))]; {whois, Val, Opts} -> [encode_whois(Val, Opts, Lang, lists:member(whois, Required))]; {mam, Val} -> [encode_mam(Val, Lang, lists:member(mam, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/muc#roomconfig">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"muc#maxhistoryfetch">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#maxhistoryfetch">>, Required), [{maxhistoryfetch, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#maxhistoryfetch">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#maxhistoryfetch">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#maxhistoryfetch">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#maxhistoryfetch">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#maxhistoryfetch">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_allowpm">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [anyone, participants, moderators, none]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_allowpm">>, Required), [{allowpm, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_allowpm">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_allowpm">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_allowpm">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_allowpm">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_allowpm">>, XMLNS}}); do_decode([#xdata_field{var = <<"allow_private_messages">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"allow_private_messages">>, Required), [{allow_private_messages, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"allow_private_messages">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_private_messages">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"allow_private_messages">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"allow_private_messages">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"allow_private_messages">>, XMLNS}}); do_decode([#xdata_field{var = <<"allow_private_messages_from_visitors">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [nobody, moderators, anyone]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"allow_private_messages_from_visitors">>, Required), [{allow_private_messages_from_visitors, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"allow_private_messages_from_visitors">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_private_messages_from_visitors">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"allow_private_messages_from_visitors">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"allow_private_messages_from_visitors">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"allow_private_messages_from_visitors">>, XMLNS}}); do_decode([#xdata_field{var = <<"allow_visitor_status">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"allow_visitor_status">>, Required), [{allow_visitor_status, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"allow_visitor_status">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_visitor_status">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"allow_visitor_status">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"allow_visitor_status">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"allow_visitor_status">>, XMLNS}}); do_decode([#xdata_field{var = <<"allow_visitor_nickchange">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"allow_visitor_nickchange">>, Required), [{allow_visitor_nickchange, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"allow_visitor_nickchange">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_visitor_nickchange">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"allow_visitor_nickchange">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"allow_visitor_nickchange">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"allow_visitor_nickchange">>, XMLNS}}); do_decode([#xdata_field{var = <<"allow_voice_requests">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"allow_voice_requests">>, Required), [{allow_voice_requests, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"allow_voice_requests">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_voice_requests">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"allow_voice_requests">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"allow_voice_requests">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"allow_voice_requests">>, XMLNS}}); do_decode([#xdata_field{var = <<"allow_subscription">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"allow_subscription">>, Required), [{allow_subscription, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"allow_subscription">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_subscription">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"allow_subscription">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"allow_subscription">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"allow_subscription">>, XMLNS}}); do_decode([#xdata_field{var = <<"voice_request_min_interval">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"voice_request_min_interval">>, Required), [{voice_request_min_interval, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"voice_request_min_interval">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"voice_request_min_interval">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"voice_request_min_interval">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"voice_request_min_interval">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"voice_request_min_interval">>, XMLNS}}); do_decode([#xdata_field{var = <<"captcha_protected">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"captcha_protected">>, Required), [{captcha_protected, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"captcha_protected">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"captcha_protected">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"captcha_protected">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"captcha_protected">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"captcha_protected">>, XMLNS}}); do_decode([#xdata_field{var = <<"captcha_whitelist">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"captcha_whitelist">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"captcha_whitelist">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"captcha_whitelist">>, Required), [{captcha_whitelist, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"captcha_whitelist">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_query_users">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"allow_query_users">>, Required), [{allow_query_users, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"allow_query_users">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"allow_query_users">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"allow_query_users">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"allow_query_users">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"allow_query_users">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_allowinvites">>, Required), [{allowinvites, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_allowinvites">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_allowinvites">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_allowinvites">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_changesubject">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_changesubject">>, Required), [{changesubject, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_changesubject">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_changesubject">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_changesubject">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_changesubject">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_changesubject">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_enablelogging">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_enablelogging">>, Required), [{enablelogging, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_enablelogging">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_enablelogging">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_enablelogging">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_enablelogging">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_enablelogging">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_getmemberlist">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [Value || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_getmemberlist">>, Required), [{getmemberlist, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_getmemberlist">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_lang">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try xmpp_lang:check(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_lang">>, Required), [{lang, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_lang">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_lang">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_lang">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_lang">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_lang">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_pubsub">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try xmpp_uri:check(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_pubsub">>, Required), [{pubsub, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_pubsub">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_pubsub">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_pubsub">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_pubsub">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_pubsub">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_maxusers">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum_int(Value, [none], 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_maxusers">>, Required), [{maxusers, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_maxusers">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_maxusers">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_maxusers">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_maxusers">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_maxusers">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_membersonly">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_membersonly">>, Required), [{membersonly, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_membersonly">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_membersonly">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_membersonly">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_membersonly">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_membersonly">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_moderatedroom">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_moderatedroom">>, Required), [{moderatedroom, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_moderatedroom">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_moderatedroom">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_moderatedroom">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_moderatedroom">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_moderatedroom">>, XMLNS}}); do_decode([#xdata_field{var = <<"members_by_default">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"members_by_default">>, Required), [{members_by_default, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"members_by_default">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"members_by_default">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"members_by_default">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"members_by_default">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"members_by_default">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_passwordprotectedroom">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_passwordprotectedroom">>, Required), [{passwordprotectedroom, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_passwordprotectedroom">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_passwordprotectedroom">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_passwordprotectedroom">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_passwordprotectedroom">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_passwordprotectedroom">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_persistentroom">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_persistentroom">>, Required), [{persistentroom, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_persistentroom">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_persistentroom">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_persistentroom">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_persistentroom">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_persistentroom">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_presencebroadcast">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [dec_enum(Value, [moderator, participant, visitor]) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_presencebroadcast">>, Required), [{presencebroadcast, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_presencebroadcast">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_publicroom">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_publicroom">>, Required), [{publicroom, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_publicroom">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_publicroom">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_publicroom">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_publicroom">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_publicroom">>, XMLNS}}); do_decode([#xdata_field{var = <<"public_list">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"public_list">>, Required), [{public_list, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"public_list">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"public_list">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"public_list">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"public_list">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"public_list">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_roomadmins">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"muc#roomconfig_roomadmins">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_roomadmins">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_roomadmins">>, Required), [{roomadmins, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_roomadmins">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_roomdesc">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_roomdesc">>, Required), [{roomdesc, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_roomdesc">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_roomdesc">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_roomdesc">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_roomdesc">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_roomdesc">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_roomname">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_roomname">>, Required), [{roomname, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_roomname">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_roomname">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_roomname">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_roomname">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_roomname">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_roomowners">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"muc#roomconfig_roomowners">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_roomowners">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_roomowners">>, Required), [{roomowners, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_roomowners">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_roomsecret">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_roomsecret">>, Required), [{roomsecret, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_roomsecret">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_roomsecret">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_roomsecret">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_roomsecret">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_roomsecret">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_whois">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [moderators, anyone]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_whois">>, Required), [{whois, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_whois">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_whois">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_whois">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_whois">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_whois">>, XMLNS}}); do_decode([#xdata_field{var = <<"mam">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"mam">>, Required), [{mam, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"mam">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"mam">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"mam">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"mam">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"mam">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_maxhistoryfetch(binary(), binary(), boolean()) -> xdata_field(). encode_maxhistoryfetch(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#maxhistoryfetch">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Maximum Number of History Messages Returned " "by Room"))}. -spec encode_allowpm(allowpm() | undefined, default | options(allowpm()), binary(), boolean()) -> xdata_field(). encode_allowpm(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone")), value = <<"anyone">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone with Voice")), value = <<"participants">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Moderators Only")), value = <<"moderators">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Nobody")), value = <<"none">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"muc#roomconfig_allowpm">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Roles that May Send Private Messages"))}. -spec encode_allow_private_messages(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow_private_messages(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"allow_private_messages">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow users to send private messages"))}. -spec encode_allow_private_messages_from_visitors(allow_private_messages_from_visitors() | undefined, default | options(allow_private_messages_from_visitors()), binary(), boolean()) -> xdata_field(). encode_allow_private_messages_from_visitors(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Nobody")), value = <<"nobody">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Moderators Only")), value = <<"moderators">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone")), value = <<"anyone">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"allow_private_messages_from_visitors">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow visitors to send private messages to"))}. -spec encode_allow_visitor_status(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow_visitor_status(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"allow_visitor_status">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow visitors to send status text in " "presence updates"))}. -spec encode_allow_visitor_nickchange(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow_visitor_nickchange(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"allow_visitor_nickchange">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow visitors to change nickname"))}. -spec encode_allow_voice_requests(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow_voice_requests(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"allow_voice_requests">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow visitors to send voice requests"))}. -spec encode_allow_subscription(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow_subscription(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"allow_subscription">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow subscription"))}. -spec encode_voice_request_min_interval(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_voice_request_min_interval(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"voice_request_min_interval">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Minimum interval between voice requests " "(in seconds)"))}. -spec encode_captcha_protected(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_captcha_protected(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"captcha_protected">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Make room CAPTCHA protected"))}. -spec encode_captcha_whitelist([jid:jid()], binary(), boolean()) -> xdata_field(). encode_captcha_whitelist(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"captcha_whitelist">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Exclude Jabber IDs from CAPTCHA challenge"))}. -spec encode_allow_query_users(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow_query_users(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"allow_query_users">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow users to query other users"))}. -spec encode_allowinvites(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allowinvites(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow users to send invites"))}. -spec encode_changesubject(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_changesubject(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_changesubject">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow users to change the subject"))}. -spec encode_enablelogging(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_enablelogging(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_enablelogging">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Enable logging"))}. -spec encode_getmemberlist([binary()], default | options(binary()), binary(), boolean()) -> xdata_field(). encode_getmemberlist(Value, Options, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> Value end, Opts = if Options == default -> []; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = V} || {L, V} <- Options] end, #xdata_field{var = <<"muc#roomconfig_getmemberlist">>, values = Values, required = IsRequired, type = 'list-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Roles and Affiliations that May Retrieve " "Member List"))}. -spec encode_lang(binary() | undefined, binary(), boolean()) -> xdata_field(). encode_lang(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_lang">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Natural Language for Room Discussions"))}. -spec encode_pubsub(binary() | undefined, binary(), boolean()) -> xdata_field(). encode_pubsub(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_pubsub">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("XMPP URI of Associated Publish-Subscribe " "Node"))}. -spec encode_maxusers(maxusers() | undefined, default | options(maxusers()), binary(), boolean()) -> xdata_field(). encode_maxusers(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum_int(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("No limit")), value = <<"none">>}, #xdata_option{value = <<"5">>}, #xdata_option{value = <<"10">>}, #xdata_option{value = <<"20">>}, #xdata_option{value = <<"30">>}, #xdata_option{value = <<"50">>}, #xdata_option{value = <<"100">>}, #xdata_option{value = <<"200">>}, #xdata_option{value = <<"500">>}, #xdata_option{value = <<"1000">>}, #xdata_option{value = <<"2000">>}, #xdata_option{value = <<"5000">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum_int(V)} || {L, V} <- Options] end, #xdata_field{var = <<"muc#roomconfig_maxusers">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Maximum Number of Occupants"))}. -spec encode_membersonly(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_membersonly(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_membersonly">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Make room members-only"))}. -spec encode_moderatedroom(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_moderatedroom(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_moderatedroom">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Make room moderated"))}. -spec encode_members_by_default(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_members_by_default(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"members_by_default">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Default users as participants"))}. -spec encode_passwordprotectedroom(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_passwordprotectedroom(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_passwordprotectedroom">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Make room password protected"))}. -spec encode_persistentroom(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_persistentroom(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_persistentroom">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Make room persistent"))}. -spec encode_presencebroadcast([presencebroadcast()], default | options(presencebroadcast()), binary(), boolean()) -> xdata_field(). encode_presencebroadcast(Value, Options, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [enc_enum(V) || V <- Value] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Moderator")), value = <<"moderator">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Participant")), value = <<"participant">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Visitor")), value = <<"visitor">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"muc#roomconfig_presencebroadcast">>, values = Values, required = IsRequired, type = 'list-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Roles for which Presence is Broadcasted"))}. -spec encode_publicroom(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_publicroom(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_publicroom">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Make room public searchable"))}. -spec encode_public_list(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_public_list(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"public_list">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Make participants list public"))}. -spec encode_roomadmins([jid:jid()], binary(), boolean()) -> xdata_field(). encode_roomadmins(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_roomadmins">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Full List of Room Admins"))}. -spec encode_roomdesc(binary(), binary(), boolean()) -> xdata_field(). encode_roomdesc(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_roomdesc">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Room description"))}. -spec encode_roomname(binary(), binary(), boolean()) -> xdata_field(). encode_roomname(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_roomname">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Room title"))}. -spec encode_roomowners([jid:jid()], binary(), boolean()) -> xdata_field(). encode_roomowners(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_roomowners">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Full List of Room Owners"))}. -spec encode_roomsecret(binary(), binary(), boolean()) -> xdata_field(). encode_roomsecret(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_roomsecret">>, values = Values, required = IsRequired, type = 'text-private', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Password"))}. -spec encode_whois(whois() | undefined, default | options(whois()), binary(), boolean()) -> xdata_field(). encode_whois(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Moderators Only")), value = <<"moderators">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone")), value = <<"anyone">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"muc#roomconfig_whois">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Present real Jabber IDs to"))}. -spec encode_mam(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_mam(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"mam">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Enable message archiving"))}. xmpp-1.4.4/src/xep0085.erl0000644000232200023220000001162413610066730015464 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0085). -compile(export_all). do_decode(<<"paused">>, <<"http://jabber.org/protocol/chatstates">>, El, Opts) -> decode_chatstate_paused(<<"http://jabber.org/protocol/chatstates">>, Opts, El); do_decode(<<"inactive">>, <<"http://jabber.org/protocol/chatstates">>, El, Opts) -> decode_chatstate_inactive(<<"http://jabber.org/protocol/chatstates">>, Opts, El); do_decode(<<"gone">>, <<"http://jabber.org/protocol/chatstates">>, El, Opts) -> decode_chatstate_gone(<<"http://jabber.org/protocol/chatstates">>, Opts, El); do_decode(<<"composing">>, <<"http://jabber.org/protocol/chatstates">>, El, Opts) -> decode_chatstate_composing(<<"http://jabber.org/protocol/chatstates">>, Opts, El); do_decode(<<"active">>, <<"http://jabber.org/protocol/chatstates">>, El, Opts) -> decode_chatstate_active(<<"http://jabber.org/protocol/chatstates">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"paused">>, <<"http://jabber.org/protocol/chatstates">>}, {<<"inactive">>, <<"http://jabber.org/protocol/chatstates">>}, {<<"gone">>, <<"http://jabber.org/protocol/chatstates">>}, {<<"composing">>, <<"http://jabber.org/protocol/chatstates">>}, {<<"active">>, <<"http://jabber.org/protocol/chatstates">>}]. do_encode({chatstate, active} = Active, TopXMLNS) -> encode_chatstate_active(Active, TopXMLNS); do_encode({chatstate, composing} = Composing, TopXMLNS) -> encode_chatstate_composing(Composing, TopXMLNS); do_encode({chatstate, gone} = Gone, TopXMLNS) -> encode_chatstate_gone(Gone, TopXMLNS); do_encode({chatstate, inactive} = Inactive, TopXMLNS) -> encode_chatstate_inactive(Inactive, TopXMLNS); do_encode({chatstate, paused} = Paused, TopXMLNS) -> encode_chatstate_paused(Paused, TopXMLNS). do_get_name({chatstate, active}) -> <<"active">>; do_get_name({chatstate, composing}) -> <<"composing">>; do_get_name({chatstate, gone}) -> <<"gone">>; do_get_name({chatstate, inactive}) -> <<"inactive">>; do_get_name({chatstate, paused}) -> <<"paused">>. do_get_ns({chatstate, active}) -> <<"http://jabber.org/protocol/chatstates">>; do_get_ns({chatstate, composing}) -> <<"http://jabber.org/protocol/chatstates">>; do_get_ns({chatstate, gone}) -> <<"http://jabber.org/protocol/chatstates">>; do_get_ns({chatstate, inactive}) -> <<"http://jabber.org/protocol/chatstates">>; do_get_ns({chatstate, paused}) -> <<"http://jabber.org/protocol/chatstates">>. pp(chatstate, 1) -> [type]; pp(_, _) -> no. records() -> [{chatstate, 1}]. decode_chatstate_paused(__TopXMLNS, __Opts, {xmlel, <<"paused">>, _attrs, _els}) -> {chatstate, paused}. encode_chatstate_paused({chatstate, paused}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/chatstates">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"paused">>, _attrs, _els}. decode_chatstate_inactive(__TopXMLNS, __Opts, {xmlel, <<"inactive">>, _attrs, _els}) -> {chatstate, inactive}. encode_chatstate_inactive({chatstate, inactive}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/chatstates">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"inactive">>, _attrs, _els}. decode_chatstate_gone(__TopXMLNS, __Opts, {xmlel, <<"gone">>, _attrs, _els}) -> {chatstate, gone}. encode_chatstate_gone({chatstate, gone}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/chatstates">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"gone">>, _attrs, _els}. decode_chatstate_composing(__TopXMLNS, __Opts, {xmlel, <<"composing">>, _attrs, _els}) -> {chatstate, composing}. encode_chatstate_composing({chatstate, composing}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/chatstates">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"composing">>, _attrs, _els}. decode_chatstate_active(__TopXMLNS, __Opts, {xmlel, <<"active">>, _attrs, _els}) -> {chatstate, active}. encode_chatstate_active({chatstate, active}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/chatstates">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"active">>, _attrs, _els}. xmpp-1.4.4/src/xep0220.erl0000644000232200023220000003244213610066730015454 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0220). -compile(export_all). do_decode(<<"dialback">>, <<"urn:xmpp:features:dialback">>, El, Opts) -> decode_db_feature(<<"urn:xmpp:features:dialback">>, Opts, El); do_decode(<<"errors">>, <<"urn:xmpp:features:dialback">>, El, Opts) -> decode_db_errors(<<"urn:xmpp:features:dialback">>, Opts, El); do_decode(<<"db:verify">>, <<"jabber:server">>, El, Opts) -> decode_db_verify(<<"jabber:server">>, Opts, El); do_decode(<<"db:result">>, <<"jabber:server">>, El, Opts) -> decode_db_result(<<"jabber:server">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"dialback">>, <<"urn:xmpp:features:dialback">>}, {<<"errors">>, <<"urn:xmpp:features:dialback">>}, {<<"db:verify">>, <<"jabber:server">>}, {<<"db:result">>, <<"jabber:server">>}]. do_encode({db_result, _, _, _, _, _} = Db_result, TopXMLNS) -> encode_db_result(Db_result, TopXMLNS); do_encode({db_verify, _, _, _, _, _, _} = Db_verify, TopXMLNS) -> encode_db_verify(Db_verify, TopXMLNS); do_encode({db_feature, _} = Dialback, TopXMLNS) -> encode_db_feature(Dialback, TopXMLNS). do_get_name({db_feature, _}) -> <<"dialback">>; do_get_name({db_result, _, _, _, _, _}) -> <<"db:result">>; do_get_name({db_verify, _, _, _, _, _, _}) -> <<"db:verify">>. do_get_ns({db_feature, _}) -> <<"urn:xmpp:features:dialback">>; do_get_ns({db_result, _, _, _, _, _}) -> <<"jabber:server">>; do_get_ns({db_verify, _, _, _, _, _, _}) -> <<"jabber:server">>. get_els({db_result, _from, _to, _type, _key, _sub_els}) -> _sub_els; get_els({db_verify, _from, _to, _id, _type, _key, _sub_els}) -> _sub_els. set_els({db_result, _from, _to, _type, _key, _}, _sub_els) -> {db_result, _from, _to, _type, _key, _sub_els}; set_els({db_verify, _from, _to, _id, _type, _key, _}, _sub_els) -> {db_verify, _from, _to, _id, _type, _key, _sub_els}. pp(db_result, 5) -> [from, to, type, key, sub_els]; pp(db_verify, 6) -> [from, to, id, type, key, sub_els]; pp(db_feature, 1) -> [errors]; pp(_, _) -> no. records() -> [{db_result, 5}, {db_verify, 6}, {db_feature, 1}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). nameprep(S) -> case jid:nameprep(S) of error -> erlang:error(badarg); S1 -> S1 end. decode_db_feature(__TopXMLNS, __Opts, {xmlel, <<"dialback">>, _attrs, _els}) -> Errors = decode_db_feature_els(__TopXMLNS, __Opts, _els, false), {db_feature, Errors}. decode_db_feature_els(__TopXMLNS, __Opts, [], Errors) -> Errors; decode_db_feature_els(__TopXMLNS, __Opts, [{xmlel, <<"errors">>, _attrs, _} = _el | _els], Errors) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:features:dialback">> -> decode_db_feature_els(__TopXMLNS, __Opts, _els, decode_db_errors(<<"urn:xmpp:features:dialback">>, __Opts, _el)); _ -> decode_db_feature_els(__TopXMLNS, __Opts, _els, Errors) end; decode_db_feature_els(__TopXMLNS, __Opts, [_ | _els], Errors) -> decode_db_feature_els(__TopXMLNS, __Opts, _els, Errors). encode_db_feature({db_feature, Errors}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:features:dialback">>, [], __TopXMLNS), _els = lists:reverse('encode_db_feature_$errors'(Errors, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"dialback">>, _attrs, _els}. 'encode_db_feature_$errors'(false, __TopXMLNS, _acc) -> _acc; 'encode_db_feature_$errors'(Errors, __TopXMLNS, _acc) -> [encode_db_errors(Errors, __TopXMLNS) | _acc]. decode_db_errors(__TopXMLNS, __Opts, {xmlel, <<"errors">>, _attrs, _els}) -> true. encode_db_errors(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:features:dialback">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"errors">>, _attrs, _els}. decode_db_verify(__TopXMLNS, __Opts, {xmlel, <<"db:verify">>, _attrs, _els}) -> {Key, __Els} = decode_db_verify_els(__TopXMLNS, __Opts, _els, <<>>, []), {From, To, Id, Type} = decode_db_verify_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {db_verify, From, To, Id, Type, Key, __Els}. decode_db_verify_els(__TopXMLNS, __Opts, [], Key, __Els) -> {decode_db_verify_cdata(__TopXMLNS, Key), lists:reverse(__Els)}; decode_db_verify_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Key, __Els) -> decode_db_verify_els(__TopXMLNS, __Opts, _els, <>, __Els); decode_db_verify_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Key, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_db_verify_els(__TopXMLNS, __Opts, _els, Key, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_db_verify_els(__TopXMLNS, __Opts, _els, Key, [_el | __Els]); Mod -> decode_db_verify_els(__TopXMLNS, __Opts, _els, Key, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end. decode_db_verify_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], _From, To, Id, Type) -> decode_db_verify_attrs(__TopXMLNS, _attrs, _val, To, Id, Type); decode_db_verify_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], From, _To, Id, Type) -> decode_db_verify_attrs(__TopXMLNS, _attrs, From, _val, Id, Type); decode_db_verify_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], From, To, _Id, Type) -> decode_db_verify_attrs(__TopXMLNS, _attrs, From, To, _val, Type); decode_db_verify_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], From, To, Id, _Type) -> decode_db_verify_attrs(__TopXMLNS, _attrs, From, To, Id, _val); decode_db_verify_attrs(__TopXMLNS, [_ | _attrs], From, To, Id, Type) -> decode_db_verify_attrs(__TopXMLNS, _attrs, From, To, Id, Type); decode_db_verify_attrs(__TopXMLNS, [], From, To, Id, Type) -> {decode_db_verify_attr_from(__TopXMLNS, From), decode_db_verify_attr_to(__TopXMLNS, To), decode_db_verify_attr_id(__TopXMLNS, Id), decode_db_verify_attr_type(__TopXMLNS, Type)}. encode_db_verify({db_verify, From, To, Id, Type, Key, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:server">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ encode_db_verify_cdata(Key, []), _attrs = encode_db_verify_attr_type(Type, encode_db_verify_attr_id(Id, encode_db_verify_attr_to(To, encode_db_verify_attr_from(From, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"db:verify">>, _attrs, _els}. decode_db_verify_attr_from(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"from">>, <<"db:verify">>, __TopXMLNS}}); decode_db_verify_attr_from(__TopXMLNS, _val) -> case catch nameprep(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"db:verify">>, __TopXMLNS}}); _res -> _res end. encode_db_verify_attr_from(_val, _acc) -> [{<<"from">>, nameprep(_val)} | _acc]. decode_db_verify_attr_to(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"to">>, <<"db:verify">>, __TopXMLNS}}); decode_db_verify_attr_to(__TopXMLNS, _val) -> case catch nameprep(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"db:verify">>, __TopXMLNS}}); _res -> _res end. encode_db_verify_attr_to(_val, _acc) -> [{<<"to">>, nameprep(_val)} | _acc]. decode_db_verify_attr_id(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"id">>, <<"db:verify">>, __TopXMLNS}}); decode_db_verify_attr_id(__TopXMLNS, _val) -> _val. encode_db_verify_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_db_verify_attr_type(__TopXMLNS, undefined) -> undefined; decode_db_verify_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [valid, invalid, error]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"db:verify">>, __TopXMLNS}}); _res -> _res end. encode_db_verify_attr_type(undefined, _acc) -> _acc; encode_db_verify_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_db_verify_cdata(__TopXMLNS, <<>>) -> <<>>; decode_db_verify_cdata(__TopXMLNS, _val) -> _val. encode_db_verify_cdata(<<>>, _acc) -> _acc; encode_db_verify_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_db_result(__TopXMLNS, __Opts, {xmlel, <<"db:result">>, _attrs, _els}) -> {Key, __Els} = decode_db_result_els(__TopXMLNS, __Opts, _els, <<>>, []), {From, To, Type} = decode_db_result_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {db_result, From, To, Type, Key, __Els}. decode_db_result_els(__TopXMLNS, __Opts, [], Key, __Els) -> {decode_db_result_cdata(__TopXMLNS, Key), lists:reverse(__Els)}; decode_db_result_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Key, __Els) -> decode_db_result_els(__TopXMLNS, __Opts, _els, <>, __Els); decode_db_result_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Key, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_db_result_els(__TopXMLNS, __Opts, _els, Key, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_db_result_els(__TopXMLNS, __Opts, _els, Key, [_el | __Els]); Mod -> decode_db_result_els(__TopXMLNS, __Opts, _els, Key, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end. decode_db_result_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], _From, To, Type) -> decode_db_result_attrs(__TopXMLNS, _attrs, _val, To, Type); decode_db_result_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], From, _To, Type) -> decode_db_result_attrs(__TopXMLNS, _attrs, From, _val, Type); decode_db_result_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], From, To, _Type) -> decode_db_result_attrs(__TopXMLNS, _attrs, From, To, _val); decode_db_result_attrs(__TopXMLNS, [_ | _attrs], From, To, Type) -> decode_db_result_attrs(__TopXMLNS, _attrs, From, To, Type); decode_db_result_attrs(__TopXMLNS, [], From, To, Type) -> {decode_db_result_attr_from(__TopXMLNS, From), decode_db_result_attr_to(__TopXMLNS, To), decode_db_result_attr_type(__TopXMLNS, Type)}. encode_db_result({db_result, From, To, Type, Key, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:server">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ encode_db_result_cdata(Key, []), _attrs = encode_db_result_attr_type(Type, encode_db_result_attr_to(To, encode_db_result_attr_from(From, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"db:result">>, _attrs, _els}. decode_db_result_attr_from(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"from">>, <<"db:result">>, __TopXMLNS}}); decode_db_result_attr_from(__TopXMLNS, _val) -> case catch nameprep(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"db:result">>, __TopXMLNS}}); _res -> _res end. encode_db_result_attr_from(_val, _acc) -> [{<<"from">>, nameprep(_val)} | _acc]. decode_db_result_attr_to(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"to">>, <<"db:result">>, __TopXMLNS}}); decode_db_result_attr_to(__TopXMLNS, _val) -> case catch nameprep(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"db:result">>, __TopXMLNS}}); _res -> _res end. encode_db_result_attr_to(_val, _acc) -> [{<<"to">>, nameprep(_val)} | _acc]. decode_db_result_attr_type(__TopXMLNS, undefined) -> undefined; decode_db_result_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [valid, invalid, error]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"db:result">>, __TopXMLNS}}); _res -> _res end. encode_db_result_attr_type(undefined, _acc) -> _acc; encode_db_result_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_db_result_cdata(__TopXMLNS, <<>>) -> <<>>; decode_db_result_cdata(__TopXMLNS, _val) -> _val. encode_db_result_cdata(<<>>, _acc) -> _acc; encode_db_result_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0023.erl0000644000232200023220000000571613610066730015461 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0023). -compile(export_all). do_decode(<<"x">>, <<"jabber:x:expire">>, El, Opts) -> decode_expire(<<"jabber:x:expire">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"x">>, <<"jabber:x:expire">>}]. do_encode({expire, _, _} = X, TopXMLNS) -> encode_expire(X, TopXMLNS). do_get_name({expire, _, _}) -> <<"x">>. do_get_ns({expire, _, _}) -> <<"jabber:x:expire">>. pp(expire, 2) -> [seconds, stored]; pp(_, _) -> no. records() -> [{expire, 2}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_expire(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> {Seconds, Stored} = decode_expire_attrs(__TopXMLNS, _attrs, undefined, undefined), {expire, Seconds, Stored}. decode_expire_attrs(__TopXMLNS, [{<<"seconds">>, _val} | _attrs], _Seconds, Stored) -> decode_expire_attrs(__TopXMLNS, _attrs, _val, Stored); decode_expire_attrs(__TopXMLNS, [{<<"stored">>, _val} | _attrs], Seconds, _Stored) -> decode_expire_attrs(__TopXMLNS, _attrs, Seconds, _val); decode_expire_attrs(__TopXMLNS, [_ | _attrs], Seconds, Stored) -> decode_expire_attrs(__TopXMLNS, _attrs, Seconds, Stored); decode_expire_attrs(__TopXMLNS, [], Seconds, Stored) -> {decode_expire_attr_seconds(__TopXMLNS, Seconds), decode_expire_attr_stored(__TopXMLNS, Stored)}. encode_expire({expire, Seconds, Stored}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:expire">>, [], __TopXMLNS), _els = [], _attrs = encode_expire_attr_stored(Stored, encode_expire_attr_seconds(Seconds, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"x">>, _attrs, _els}. decode_expire_attr_seconds(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"seconds">>, <<"x">>, __TopXMLNS}}); decode_expire_attr_seconds(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"seconds">>, <<"x">>, __TopXMLNS}}); _res -> _res end. encode_expire_attr_seconds(_val, _acc) -> [{<<"seconds">>, enc_int(_val)} | _acc]. decode_expire_attr_stored(__TopXMLNS, undefined) -> undefined; decode_expire_attr_stored(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"stored">>, <<"x">>, __TopXMLNS}}); _res -> _res end. encode_expire_attr_stored(undefined, _acc) -> _acc; encode_expire_attr_stored(_val, _acc) -> [{<<"stored">>, enc_int(_val)} | _acc]. xmpp-1.4.4/src/xep0417.erl0000644000232200023220000005661613610066730015475 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0417). -compile(export_all). do_decode(<<"x509-register">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_register(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-challenge-failed">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_challenge_failed(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-challenge">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_challenge(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-revoke">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_revoke(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-request">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_request(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-signature">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_signature(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-ca-list">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_ca_list(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-cert-chain">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_cert_chain(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-csr">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_csr(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(<<"x509-cert">>, <<"urn:xmpp:x509:0">>, El, Opts) -> decode_x509_cert(<<"urn:xmpp:x509:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"x509-register">>, <<"urn:xmpp:x509:0">>}, {<<"x509-challenge-failed">>, <<"urn:xmpp:x509:0">>}, {<<"x509-challenge">>, <<"urn:xmpp:x509:0">>}, {<<"x509-revoke">>, <<"urn:xmpp:x509:0">>}, {<<"x509-request">>, <<"urn:xmpp:x509:0">>}, {<<"x509-signature">>, <<"urn:xmpp:x509:0">>}, {<<"x509-ca-list">>, <<"urn:xmpp:x509:0">>}, {<<"x509-cert-chain">>, <<"urn:xmpp:x509:0">>}, {<<"x509-csr">>, <<"urn:xmpp:x509:0">>}, {<<"x509-cert">>, <<"urn:xmpp:x509:0">>}]. do_encode({x509_csr, _, _} = X509_csr, TopXMLNS) -> encode_x509_csr(X509_csr, TopXMLNS); do_encode({x509_cert_chain, _, _} = X509_cert_chain, TopXMLNS) -> encode_x509_cert_chain(X509_cert_chain, TopXMLNS); do_encode({x509_ca_list, _} = X509_ca_list, TopXMLNS) -> encode_x509_ca_list(X509_ca_list, TopXMLNS); do_encode({x509_request, _, _, _, _} = X509_request, TopXMLNS) -> encode_x509_request(X509_request, TopXMLNS); do_encode({x509_revoke, _, _} = X509_revoke, TopXMLNS) -> encode_x509_revoke(X509_revoke, TopXMLNS); do_encode({x509_challenge, _, _, _} = X509_challenge, TopXMLNS) -> encode_x509_challenge(X509_challenge, TopXMLNS); do_encode({x509_challenge_failed} = X509_challenge_failed, TopXMLNS) -> encode_x509_challenge_failed(X509_challenge_failed, TopXMLNS); do_encode({x509_register} = X509_register, TopXMLNS) -> encode_x509_register(X509_register, TopXMLNS). do_get_name({x509_ca_list, _}) -> <<"x509-ca-list">>; do_get_name({x509_cert_chain, _, _}) -> <<"x509-cert-chain">>; do_get_name({x509_challenge, _, _, _}) -> <<"x509-challenge">>; do_get_name({x509_challenge_failed}) -> <<"x509-challenge-failed">>; do_get_name({x509_csr, _, _}) -> <<"x509-csr">>; do_get_name({x509_register}) -> <<"x509-register">>; do_get_name({x509_request, _, _, _, _}) -> <<"x509-request">>; do_get_name({x509_revoke, _, _}) -> <<"x509-revoke">>. do_get_ns({x509_ca_list, _}) -> <<"urn:xmpp:x509:0">>; do_get_ns({x509_cert_chain, _, _}) -> <<"urn:xmpp:x509:0">>; do_get_ns({x509_challenge, _, _, _}) -> <<"urn:xmpp:x509:0">>; do_get_ns({x509_challenge_failed}) -> <<"urn:xmpp:x509:0">>; do_get_ns({x509_csr, _, _}) -> <<"urn:xmpp:x509:0">>; do_get_ns({x509_register}) -> <<"urn:xmpp:x509:0">>; do_get_ns({x509_request, _, _, _, _}) -> <<"urn:xmpp:x509:0">>; do_get_ns({x509_revoke, _, _}) -> <<"urn:xmpp:x509:0">>. pp(x509_csr, 2) -> [name, der]; pp(x509_cert_chain, 2) -> [name, certs]; pp(x509_ca_list, 1) -> [certs]; pp(x509_request, 4) -> [transaction, csr, cert, signature]; pp(x509_revoke, 2) -> [cert, signature]; pp(x509_challenge, 3) -> [transaction, uri, signature]; pp(x509_challenge_failed, 0) -> []; pp(x509_register, 0) -> []; pp(_, _) -> no. records() -> [{x509_csr, 2}, {x509_cert_chain, 2}, {x509_ca_list, 1}, {x509_request, 4}, {x509_revoke, 2}, {x509_challenge, 3}, {x509_challenge_failed, 0}, {x509_register, 0}]. decode_x509_register(__TopXMLNS, __Opts, {xmlel, <<"x509-register">>, _attrs, _els}) -> {x509_register}. encode_x509_register({x509_register}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x509-register">>, _attrs, _els}. decode_x509_challenge_failed(__TopXMLNS, __Opts, {xmlel, <<"x509-challenge-failed">>, _attrs, _els}) -> {x509_challenge_failed}. encode_x509_challenge_failed({x509_challenge_failed}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x509-challenge-failed">>, _attrs, _els}. decode_x509_challenge(__TopXMLNS, __Opts, {xmlel, <<"x509-challenge">>, _attrs, _els}) -> Signature = decode_x509_challenge_els(__TopXMLNS, __Opts, _els, error), {Transaction, Uri} = decode_x509_challenge_attrs(__TopXMLNS, _attrs, undefined, undefined), {x509_challenge, Transaction, Uri, Signature}. decode_x509_challenge_els(__TopXMLNS, __Opts, [], Signature) -> case Signature of error -> erlang:error({xmpp_codec, {missing_tag, <<"x509-signature">>, __TopXMLNS}}); {value, Signature1} -> Signature1 end; decode_x509_challenge_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-signature">>, _attrs, _} = _el | _els], Signature) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_challenge_els(__TopXMLNS, __Opts, _els, {value, decode_x509_signature(<<"urn:xmpp:x509:0">>, __Opts, _el)}); _ -> decode_x509_challenge_els(__TopXMLNS, __Opts, _els, Signature) end; decode_x509_challenge_els(__TopXMLNS, __Opts, [_ | _els], Signature) -> decode_x509_challenge_els(__TopXMLNS, __Opts, _els, Signature). decode_x509_challenge_attrs(__TopXMLNS, [{<<"transaction">>, _val} | _attrs], _Transaction, Uri) -> decode_x509_challenge_attrs(__TopXMLNS, _attrs, _val, Uri); decode_x509_challenge_attrs(__TopXMLNS, [{<<"uri">>, _val} | _attrs], Transaction, _Uri) -> decode_x509_challenge_attrs(__TopXMLNS, _attrs, Transaction, _val); decode_x509_challenge_attrs(__TopXMLNS, [_ | _attrs], Transaction, Uri) -> decode_x509_challenge_attrs(__TopXMLNS, _attrs, Transaction, Uri); decode_x509_challenge_attrs(__TopXMLNS, [], Transaction, Uri) -> {decode_x509_challenge_attr_transaction(__TopXMLNS, Transaction), decode_x509_challenge_attr_uri(__TopXMLNS, Uri)}. encode_x509_challenge({x509_challenge, Transaction, Uri, Signature}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = lists:reverse('encode_x509_challenge_$signature'(Signature, __NewTopXMLNS, [])), _attrs = encode_x509_challenge_attr_uri(Uri, encode_x509_challenge_attr_transaction(Transaction, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"x509-challenge">>, _attrs, _els}. 'encode_x509_challenge_$signature'(Signature, __TopXMLNS, _acc) -> [encode_x509_signature(Signature, __TopXMLNS) | _acc]. decode_x509_challenge_attr_transaction(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"transaction">>, <<"x509-challenge">>, __TopXMLNS}}); decode_x509_challenge_attr_transaction(__TopXMLNS, _val) -> _val. encode_x509_challenge_attr_transaction(_val, _acc) -> [{<<"transaction">>, _val} | _acc]. decode_x509_challenge_attr_uri(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"uri">>, <<"x509-challenge">>, __TopXMLNS}}); decode_x509_challenge_attr_uri(__TopXMLNS, _val) -> _val. encode_x509_challenge_attr_uri(_val, _acc) -> [{<<"uri">>, _val} | _acc]. decode_x509_revoke(__TopXMLNS, __Opts, {xmlel, <<"x509-revoke">>, _attrs, _els}) -> {Cert, Signature} = decode_x509_revoke_els(__TopXMLNS, __Opts, _els, error, error), {x509_revoke, Cert, Signature}. decode_x509_revoke_els(__TopXMLNS, __Opts, [], Cert, Signature) -> {case Cert of error -> erlang:error({xmpp_codec, {missing_tag, <<"x509-cert">>, __TopXMLNS}}); {value, Cert1} -> Cert1 end, case Signature of error -> erlang:error({xmpp_codec, {missing_tag, <<"x509-signature">>, __TopXMLNS}}); {value, Signature1} -> Signature1 end}; decode_x509_revoke_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-cert">>, _attrs, _} = _el | _els], Cert, Signature) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_revoke_els(__TopXMLNS, __Opts, _els, {value, decode_x509_cert(<<"urn:xmpp:x509:0">>, __Opts, _el)}, Signature); _ -> decode_x509_revoke_els(__TopXMLNS, __Opts, _els, Cert, Signature) end; decode_x509_revoke_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-signature">>, _attrs, _} = _el | _els], Cert, Signature) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_revoke_els(__TopXMLNS, __Opts, _els, Cert, {value, decode_x509_signature(<<"urn:xmpp:x509:0">>, __Opts, _el)}); _ -> decode_x509_revoke_els(__TopXMLNS, __Opts, _els, Cert, Signature) end; decode_x509_revoke_els(__TopXMLNS, __Opts, [_ | _els], Cert, Signature) -> decode_x509_revoke_els(__TopXMLNS, __Opts, _els, Cert, Signature). encode_x509_revoke({x509_revoke, Cert, Signature}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = lists:reverse('encode_x509_revoke_$cert'(Cert, __NewTopXMLNS, 'encode_x509_revoke_$signature'(Signature, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x509-revoke">>, _attrs, _els}. 'encode_x509_revoke_$cert'(Cert, __TopXMLNS, _acc) -> [encode_x509_cert(Cert, __TopXMLNS) | _acc]. 'encode_x509_revoke_$signature'(Signature, __TopXMLNS, _acc) -> [encode_x509_signature(Signature, __TopXMLNS) | _acc]. decode_x509_request(__TopXMLNS, __Opts, {xmlel, <<"x509-request">>, _attrs, _els}) -> {Csr, Cert, Signature} = decode_x509_request_els(__TopXMLNS, __Opts, _els, error, undefined, undefined), Transaction = decode_x509_request_attrs(__TopXMLNS, _attrs, undefined), {x509_request, Transaction, Csr, Cert, Signature}. decode_x509_request_els(__TopXMLNS, __Opts, [], Csr, Cert, Signature) -> {case Csr of error -> erlang:error({xmpp_codec, {missing_tag, <<"x509-csr">>, __TopXMLNS}}); {value, Csr1} -> Csr1 end, Cert, Signature}; decode_x509_request_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-csr">>, _attrs, _} = _el | _els], Csr, Cert, Signature) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_request_els(__TopXMLNS, __Opts, _els, {value, decode_x509_csr(<<"urn:xmpp:x509:0">>, __Opts, _el)}, Cert, Signature); _ -> decode_x509_request_els(__TopXMLNS, __Opts, _els, Csr, Cert, Signature) end; decode_x509_request_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-cert">>, _attrs, _} = _el | _els], Csr, Cert, Signature) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_request_els(__TopXMLNS, __Opts, _els, Csr, decode_x509_cert(<<"urn:xmpp:x509:0">>, __Opts, _el), Signature); _ -> decode_x509_request_els(__TopXMLNS, __Opts, _els, Csr, Cert, Signature) end; decode_x509_request_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-signature">>, _attrs, _} = _el | _els], Csr, Cert, Signature) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_request_els(__TopXMLNS, __Opts, _els, Csr, Cert, decode_x509_signature(<<"urn:xmpp:x509:0">>, __Opts, _el)); _ -> decode_x509_request_els(__TopXMLNS, __Opts, _els, Csr, Cert, Signature) end; decode_x509_request_els(__TopXMLNS, __Opts, [_ | _els], Csr, Cert, Signature) -> decode_x509_request_els(__TopXMLNS, __Opts, _els, Csr, Cert, Signature). decode_x509_request_attrs(__TopXMLNS, [{<<"transaction">>, _val} | _attrs], _Transaction) -> decode_x509_request_attrs(__TopXMLNS, _attrs, _val); decode_x509_request_attrs(__TopXMLNS, [_ | _attrs], Transaction) -> decode_x509_request_attrs(__TopXMLNS, _attrs, Transaction); decode_x509_request_attrs(__TopXMLNS, [], Transaction) -> decode_x509_request_attr_transaction(__TopXMLNS, Transaction). encode_x509_request({x509_request, Transaction, Csr, Cert, Signature}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = lists:reverse('encode_x509_request_$csr'(Csr, __NewTopXMLNS, 'encode_x509_request_$cert'(Cert, __NewTopXMLNS, 'encode_x509_request_$signature'(Signature, __NewTopXMLNS, [])))), _attrs = encode_x509_request_attr_transaction(Transaction, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"x509-request">>, _attrs, _els}. 'encode_x509_request_$csr'(Csr, __TopXMLNS, _acc) -> [encode_x509_csr(Csr, __TopXMLNS) | _acc]. 'encode_x509_request_$cert'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_x509_request_$cert'(Cert, __TopXMLNS, _acc) -> [encode_x509_cert(Cert, __TopXMLNS) | _acc]. 'encode_x509_request_$signature'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_x509_request_$signature'(Signature, __TopXMLNS, _acc) -> [encode_x509_signature(Signature, __TopXMLNS) | _acc]. decode_x509_request_attr_transaction(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"transaction">>, <<"x509-request">>, __TopXMLNS}}); decode_x509_request_attr_transaction(__TopXMLNS, _val) -> _val. encode_x509_request_attr_transaction(_val, _acc) -> [{<<"transaction">>, _val} | _acc]. decode_x509_signature(__TopXMLNS, __Opts, {xmlel, <<"x509-signature">>, _attrs, _els}) -> Cdata = decode_x509_signature_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_x509_signature_els(__TopXMLNS, __Opts, [], Cdata) -> decode_x509_signature_cdata(__TopXMLNS, Cdata); decode_x509_signature_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_x509_signature_els(__TopXMLNS, __Opts, _els, <>); decode_x509_signature_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_x509_signature_els(__TopXMLNS, __Opts, _els, Cdata). encode_x509_signature(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = encode_x509_signature_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x509-signature">>, _attrs, _els}. decode_x509_signature_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"x509-signature">>, __TopXMLNS}}); decode_x509_signature_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"x509-signature">>, __TopXMLNS}}); _res -> _res end. encode_x509_signature_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_x509_ca_list(__TopXMLNS, __Opts, {xmlel, <<"x509-ca-list">>, _attrs, _els}) -> Certs = decode_x509_ca_list_els(__TopXMLNS, __Opts, _els, []), {x509_ca_list, Certs}. decode_x509_ca_list_els(__TopXMLNS, __Opts, [], Certs) -> lists:reverse(Certs); decode_x509_ca_list_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-cert">>, _attrs, _} = _el | _els], Certs) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_ca_list_els(__TopXMLNS, __Opts, _els, [decode_x509_cert(<<"urn:xmpp:x509:0">>, __Opts, _el) | Certs]); _ -> decode_x509_ca_list_els(__TopXMLNS, __Opts, _els, Certs) end; decode_x509_ca_list_els(__TopXMLNS, __Opts, [_ | _els], Certs) -> decode_x509_ca_list_els(__TopXMLNS, __Opts, _els, Certs). encode_x509_ca_list({x509_ca_list, Certs}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = lists:reverse('encode_x509_ca_list_$certs'(Certs, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x509-ca-list">>, _attrs, _els}. 'encode_x509_ca_list_$certs'([], __TopXMLNS, _acc) -> _acc; 'encode_x509_ca_list_$certs'([Certs | _els], __TopXMLNS, _acc) -> 'encode_x509_ca_list_$certs'(_els, __TopXMLNS, [encode_x509_cert(Certs, __TopXMLNS) | _acc]). decode_x509_cert_chain(__TopXMLNS, __Opts, {xmlel, <<"x509-cert-chain">>, _attrs, _els}) -> Certs = decode_x509_cert_chain_els(__TopXMLNS, __Opts, _els, []), Name = decode_x509_cert_chain_attrs(__TopXMLNS, _attrs, undefined), {x509_cert_chain, Name, Certs}. decode_x509_cert_chain_els(__TopXMLNS, __Opts, [], Certs) -> lists:reverse(Certs); decode_x509_cert_chain_els(__TopXMLNS, __Opts, [{xmlel, <<"x509-cert">>, _attrs, _} = _el | _els], Certs) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:x509:0">> -> decode_x509_cert_chain_els(__TopXMLNS, __Opts, _els, [decode_x509_cert(<<"urn:xmpp:x509:0">>, __Opts, _el) | Certs]); _ -> decode_x509_cert_chain_els(__TopXMLNS, __Opts, _els, Certs) end; decode_x509_cert_chain_els(__TopXMLNS, __Opts, [_ | _els], Certs) -> decode_x509_cert_chain_els(__TopXMLNS, __Opts, _els, Certs). decode_x509_cert_chain_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name) -> decode_x509_cert_chain_attrs(__TopXMLNS, _attrs, _val); decode_x509_cert_chain_attrs(__TopXMLNS, [_ | _attrs], Name) -> decode_x509_cert_chain_attrs(__TopXMLNS, _attrs, Name); decode_x509_cert_chain_attrs(__TopXMLNS, [], Name) -> decode_x509_cert_chain_attr_name(__TopXMLNS, Name). encode_x509_cert_chain({x509_cert_chain, Name, Certs}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = lists:reverse('encode_x509_cert_chain_$certs'(Certs, __NewTopXMLNS, [])), _attrs = encode_x509_cert_chain_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"x509-cert-chain">>, _attrs, _els}. 'encode_x509_cert_chain_$certs'([], __TopXMLNS, _acc) -> _acc; 'encode_x509_cert_chain_$certs'([Certs | _els], __TopXMLNS, _acc) -> 'encode_x509_cert_chain_$certs'(_els, __TopXMLNS, [encode_x509_cert(Certs, __TopXMLNS) | _acc]). decode_x509_cert_chain_attr_name(__TopXMLNS, undefined) -> <<>>; decode_x509_cert_chain_attr_name(__TopXMLNS, _val) -> _val. encode_x509_cert_chain_attr_name(<<>>, _acc) -> _acc; encode_x509_cert_chain_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_x509_csr(__TopXMLNS, __Opts, {xmlel, <<"x509-csr">>, _attrs, _els}) -> Der = decode_x509_csr_els(__TopXMLNS, __Opts, _els, <<>>), Name = decode_x509_csr_attrs(__TopXMLNS, _attrs, undefined), {x509_csr, Name, Der}. decode_x509_csr_els(__TopXMLNS, __Opts, [], Der) -> decode_x509_csr_cdata(__TopXMLNS, Der); decode_x509_csr_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Der) -> decode_x509_csr_els(__TopXMLNS, __Opts, _els, <>); decode_x509_csr_els(__TopXMLNS, __Opts, [_ | _els], Der) -> decode_x509_csr_els(__TopXMLNS, __Opts, _els, Der). decode_x509_csr_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name) -> decode_x509_csr_attrs(__TopXMLNS, _attrs, _val); decode_x509_csr_attrs(__TopXMLNS, [_ | _attrs], Name) -> decode_x509_csr_attrs(__TopXMLNS, _attrs, Name); decode_x509_csr_attrs(__TopXMLNS, [], Name) -> decode_x509_csr_attr_name(__TopXMLNS, Name). encode_x509_csr({x509_csr, Name, Der}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = encode_x509_csr_cdata(Der, []), _attrs = encode_x509_csr_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"x509-csr">>, _attrs, _els}. decode_x509_csr_attr_name(__TopXMLNS, undefined) -> <<>>; decode_x509_csr_attr_name(__TopXMLNS, _val) -> _val. encode_x509_csr_attr_name(<<>>, _acc) -> _acc; encode_x509_csr_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_x509_csr_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"x509-csr">>, __TopXMLNS}}); decode_x509_csr_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"x509-csr">>, __TopXMLNS}}); _res -> _res end. encode_x509_csr_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_x509_cert(__TopXMLNS, __Opts, {xmlel, <<"x509-cert">>, _attrs, _els}) -> Cdata = decode_x509_cert_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_x509_cert_els(__TopXMLNS, __Opts, [], Cdata) -> decode_x509_cert_cdata(__TopXMLNS, Cdata); decode_x509_cert_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_x509_cert_els(__TopXMLNS, __Opts, _els, <>); decode_x509_cert_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_x509_cert_els(__TopXMLNS, __Opts, _els, Cdata). encode_x509_cert(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:x509:0">>, [], __TopXMLNS), _els = encode_x509_cert_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x509-cert">>, _attrs, _els}. decode_x509_cert_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"x509-cert">>, __TopXMLNS}}); decode_x509_cert_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"x509-cert">>, __TopXMLNS}}); _res -> _res end. encode_x509_cert_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. xmpp-1.4.4/src/xmpp_stream.erl0000644000232200023220000000230513610066730016706 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_stream). %% API -export([new_id/0]). %%%=================================================================== %%% API %%%=================================================================== -spec new_id() -> binary(). new_id() -> p1_rand:get_string(). %%%=================================================================== %%% Internal functions %%%=================================================================== xmpp-1.4.4/src/xep0199.erl0000644000232200023220000000177513610066730015500 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0199). -compile(export_all). do_decode(<<"ping">>, <<"urn:xmpp:ping">>, El, Opts) -> decode_ping(<<"urn:xmpp:ping">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"ping">>, <<"urn:xmpp:ping">>}]. do_encode({ping} = Ping, TopXMLNS) -> encode_ping(Ping, TopXMLNS). do_get_name({ping}) -> <<"ping">>. do_get_ns({ping}) -> <<"urn:xmpp:ping">>. pp(ping, 0) -> []; pp(_, _) -> no. records() -> [{ping, 0}]. decode_ping(__TopXMLNS, __Opts, {xmlel, <<"ping">>, _attrs, _els}) -> {ping}. encode_ping({ping}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:ping">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ping">>, _attrs, _els}. xmpp-1.4.4/src/xep0039.erl0000644000232200023220000002202113610066730015454 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0039). -compile(export_all). do_decode(<<"query">>, <<"http://jabber.org/protocol/stats">>, El, Opts) -> decode_stats(<<"http://jabber.org/protocol/stats">>, Opts, El); do_decode(<<"stat">>, <<"http://jabber.org/protocol/stats">>, El, Opts) -> decode_stat(<<"http://jabber.org/protocol/stats">>, Opts, El); do_decode(<<"error">>, <<"http://jabber.org/protocol/stats">>, El, Opts) -> decode_stat_error(<<"http://jabber.org/protocol/stats">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"http://jabber.org/protocol/stats">>}, {<<"stat">>, <<"http://jabber.org/protocol/stats">>}, {<<"error">>, <<"http://jabber.org/protocol/stats">>}]. do_encode({stat_error, _, _} = Error, TopXMLNS) -> encode_stat_error(Error, TopXMLNS); do_encode({stat, _, _, _, _} = Stat, TopXMLNS) -> encode_stat(Stat, TopXMLNS); do_encode({stats, _, _} = Query, TopXMLNS) -> encode_stats(Query, TopXMLNS). do_get_name({stat, _, _, _, _}) -> <<"stat">>; do_get_name({stat_error, _, _}) -> <<"error">>; do_get_name({stats, _, _}) -> <<"query">>. do_get_ns({stat, _, _, _, _}) -> <<"http://jabber.org/protocol/stats">>; do_get_ns({stat_error, _, _}) -> <<"http://jabber.org/protocol/stats">>; do_get_ns({stats, _, _}) -> <<"http://jabber.org/protocol/stats">>. pp(stat_error, 2) -> [code, reason]; pp(stat, 4) -> [name, units, value, error]; pp(stats, 2) -> [list, node]; pp(_, _) -> no. records() -> [{stat_error, 2}, {stat, 4}, {stats, 2}]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_stats(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> List = decode_stats_els(__TopXMLNS, __Opts, _els, []), Node = decode_stats_attrs(__TopXMLNS, _attrs, undefined), {stats, List, Node}. decode_stats_els(__TopXMLNS, __Opts, [], List) -> lists:reverse(List); decode_stats_els(__TopXMLNS, __Opts, [{xmlel, <<"stat">>, _attrs, _} = _el | _els], List) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/stats">> -> decode_stats_els(__TopXMLNS, __Opts, _els, [decode_stat(<<"http://jabber.org/protocol/stats">>, __Opts, _el) | List]); _ -> decode_stats_els(__TopXMLNS, __Opts, _els, List) end; decode_stats_els(__TopXMLNS, __Opts, [_ | _els], List) -> decode_stats_els(__TopXMLNS, __Opts, _els, List). decode_stats_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_stats_attrs(__TopXMLNS, _attrs, _val); decode_stats_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_stats_attrs(__TopXMLNS, _attrs, Node); decode_stats_attrs(__TopXMLNS, [], Node) -> decode_stats_attr_node(__TopXMLNS, Node). encode_stats({stats, List, Node}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/stats">>, [], __TopXMLNS), _els = lists:reverse('encode_stats_$list'(List, __NewTopXMLNS, [])), _attrs = encode_stats_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"query">>, _attrs, _els}. 'encode_stats_$list'([], __TopXMLNS, _acc) -> _acc; 'encode_stats_$list'([List | _els], __TopXMLNS, _acc) -> 'encode_stats_$list'(_els, __TopXMLNS, [encode_stat(List, __TopXMLNS) | _acc]). decode_stats_attr_node(__TopXMLNS, undefined) -> <<>>; decode_stats_attr_node(__TopXMLNS, _val) -> _val. encode_stats_attr_node(<<>>, _acc) -> _acc; encode_stats_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_stat(__TopXMLNS, __Opts, {xmlel, <<"stat">>, _attrs, _els}) -> Error = decode_stat_els(__TopXMLNS, __Opts, _els, undefined), {Name, Units, Value} = decode_stat_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {stat, Name, Units, Value, Error}. decode_stat_els(__TopXMLNS, __Opts, [], Error) -> Error; decode_stat_els(__TopXMLNS, __Opts, [{xmlel, <<"error">>, _attrs, _} = _el | _els], Error) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/stats">> -> decode_stat_els(__TopXMLNS, __Opts, _els, decode_stat_error(<<"http://jabber.org/protocol/stats">>, __Opts, _el)); _ -> decode_stat_els(__TopXMLNS, __Opts, _els, Error) end; decode_stat_els(__TopXMLNS, __Opts, [_ | _els], Error) -> decode_stat_els(__TopXMLNS, __Opts, _els, Error). decode_stat_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name, Units, Value) -> decode_stat_attrs(__TopXMLNS, _attrs, _val, Units, Value); decode_stat_attrs(__TopXMLNS, [{<<"units">>, _val} | _attrs], Name, _Units, Value) -> decode_stat_attrs(__TopXMLNS, _attrs, Name, _val, Value); decode_stat_attrs(__TopXMLNS, [{<<"value">>, _val} | _attrs], Name, Units, _Value) -> decode_stat_attrs(__TopXMLNS, _attrs, Name, Units, _val); decode_stat_attrs(__TopXMLNS, [_ | _attrs], Name, Units, Value) -> decode_stat_attrs(__TopXMLNS, _attrs, Name, Units, Value); decode_stat_attrs(__TopXMLNS, [], Name, Units, Value) -> {decode_stat_attr_name(__TopXMLNS, Name), decode_stat_attr_units(__TopXMLNS, Units), decode_stat_attr_value(__TopXMLNS, Value)}. encode_stat({stat, Name, Units, Value, Error}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/stats">>, [], __TopXMLNS), _els = lists:reverse('encode_stat_$error'(Error, __NewTopXMLNS, [])), _attrs = encode_stat_attr_value(Value, encode_stat_attr_units(Units, encode_stat_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"stat">>, _attrs, _els}. 'encode_stat_$error'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_stat_$error'(Error, __TopXMLNS, _acc) -> [encode_stat_error(Error, __TopXMLNS) | _acc]. decode_stat_attr_name(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"name">>, <<"stat">>, __TopXMLNS}}); decode_stat_attr_name(__TopXMLNS, _val) -> _val. encode_stat_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_stat_attr_units(__TopXMLNS, undefined) -> <<>>; decode_stat_attr_units(__TopXMLNS, _val) -> _val. encode_stat_attr_units(<<>>, _acc) -> _acc; encode_stat_attr_units(_val, _acc) -> [{<<"units">>, _val} | _acc]. decode_stat_attr_value(__TopXMLNS, undefined) -> <<>>; decode_stat_attr_value(__TopXMLNS, _val) -> _val. encode_stat_attr_value(<<>>, _acc) -> _acc; encode_stat_attr_value(_val, _acc) -> [{<<"value">>, _val} | _acc]. decode_stat_error(__TopXMLNS, __Opts, {xmlel, <<"error">>, _attrs, _els}) -> Reason = decode_stat_error_els(__TopXMLNS, __Opts, _els, <<>>), Code = decode_stat_error_attrs(__TopXMLNS, _attrs, undefined), {stat_error, Code, Reason}. decode_stat_error_els(__TopXMLNS, __Opts, [], Reason) -> decode_stat_error_cdata(__TopXMLNS, Reason); decode_stat_error_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Reason) -> decode_stat_error_els(__TopXMLNS, __Opts, _els, <>); decode_stat_error_els(__TopXMLNS, __Opts, [_ | _els], Reason) -> decode_stat_error_els(__TopXMLNS, __Opts, _els, Reason). decode_stat_error_attrs(__TopXMLNS, [{<<"code">>, _val} | _attrs], _Code) -> decode_stat_error_attrs(__TopXMLNS, _attrs, _val); decode_stat_error_attrs(__TopXMLNS, [_ | _attrs], Code) -> decode_stat_error_attrs(__TopXMLNS, _attrs, Code); decode_stat_error_attrs(__TopXMLNS, [], Code) -> decode_stat_error_attr_code(__TopXMLNS, Code). encode_stat_error({stat_error, Code, Reason}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/stats">>, [], __TopXMLNS), _els = encode_stat_error_cdata(Reason, []), _attrs = encode_stat_error_attr_code(Code, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"error">>, _attrs, _els}. decode_stat_error_attr_code(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"code">>, <<"error">>, __TopXMLNS}}); decode_stat_error_attr_code(__TopXMLNS, _val) -> case catch dec_int(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"code">>, <<"error">>, __TopXMLNS}}); _res -> _res end. encode_stat_error_attr_code(_val, _acc) -> [{<<"code">>, enc_int(_val)} | _acc]. decode_stat_error_cdata(__TopXMLNS, <<>>) -> <<>>; decode_stat_error_cdata(__TopXMLNS, _val) -> _val. encode_stat_error_cdata(<<>>, _acc) -> _acc; encode_stat_error_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0016.erl0000644000232200023220000005010713610066730015455 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0016). -compile(export_all). do_decode(<<"query">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"active">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_active_list(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"default">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_default_list(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"list">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_list(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"item">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_item(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"presence-out">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_presence_out(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"presence-in">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_presence_in(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"iq">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_iq(<<"jabber:iq:privacy">>, Opts, El); do_decode(<<"message">>, <<"jabber:iq:privacy">>, El, Opts) -> decode_privacy_message(<<"jabber:iq:privacy">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"jabber:iq:privacy">>}, {<<"active">>, <<"jabber:iq:privacy">>}, {<<"default">>, <<"jabber:iq:privacy">>}, {<<"list">>, <<"jabber:iq:privacy">>}, {<<"item">>, <<"jabber:iq:privacy">>}, {<<"presence-out">>, <<"jabber:iq:privacy">>}, {<<"presence-in">>, <<"jabber:iq:privacy">>}, {<<"iq">>, <<"jabber:iq:privacy">>}, {<<"message">>, <<"jabber:iq:privacy">>}]. do_encode({privacy_item, _, _, _, _, _, _, _, _} = Item, TopXMLNS) -> encode_privacy_item(Item, TopXMLNS); do_encode({privacy_list, _, _} = List, TopXMLNS) -> encode_privacy_list(List, TopXMLNS); do_encode({privacy_query, _, _, _} = Query, TopXMLNS) -> encode_privacy(Query, TopXMLNS). do_get_name({privacy_item, _, _, _, _, _, _, _, _}) -> <<"item">>; do_get_name({privacy_list, _, _}) -> <<"list">>; do_get_name({privacy_query, _, _, _}) -> <<"query">>. do_get_ns({privacy_item, _, _, _, _, _, _, _, _}) -> <<"jabber:iq:privacy">>; do_get_ns({privacy_list, _, _}) -> <<"jabber:iq:privacy">>; do_get_ns({privacy_query, _, _, _}) -> <<"jabber:iq:privacy">>. pp(privacy_item, 8) -> [order, action, type, value, message, iq, presence_in, presence_out]; pp(privacy_list, 2) -> [name, items]; pp(privacy_query, 3) -> [lists, default, active]; pp(_, _) -> no. records() -> [{privacy_item, 8}, {privacy_list, 2}, {privacy_query, 3}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). decode_privacy(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Lists, Default, Active} = decode_privacy_els(__TopXMLNS, __Opts, _els, [], undefined, undefined), {privacy_query, Lists, Default, Active}. decode_privacy_els(__TopXMLNS, __Opts, [], Lists, Default, Active) -> {lists:reverse(Lists), Default, Active}; decode_privacy_els(__TopXMLNS, __Opts, [{xmlel, <<"list">>, _attrs, _} = _el | _els], Lists, Default, Active) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_els(__TopXMLNS, __Opts, _els, [decode_privacy_list(<<"jabber:iq:privacy">>, __Opts, _el) | Lists], Default, Active); _ -> decode_privacy_els(__TopXMLNS, __Opts, _els, Lists, Default, Active) end; decode_privacy_els(__TopXMLNS, __Opts, [{xmlel, <<"default">>, _attrs, _} = _el | _els], Lists, Default, Active) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_els(__TopXMLNS, __Opts, _els, Lists, decode_privacy_default_list(<<"jabber:iq:privacy">>, __Opts, _el), Active); _ -> decode_privacy_els(__TopXMLNS, __Opts, _els, Lists, Default, Active) end; decode_privacy_els(__TopXMLNS, __Opts, [{xmlel, <<"active">>, _attrs, _} = _el | _els], Lists, Default, Active) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_els(__TopXMLNS, __Opts, _els, Lists, Default, decode_privacy_active_list(<<"jabber:iq:privacy">>, __Opts, _el)); _ -> decode_privacy_els(__TopXMLNS, __Opts, _els, Lists, Default, Active) end; decode_privacy_els(__TopXMLNS, __Opts, [_ | _els], Lists, Default, Active) -> decode_privacy_els(__TopXMLNS, __Opts, _els, Lists, Default, Active). encode_privacy({privacy_query, Lists, Default, Active}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = lists:reverse('encode_privacy_$lists'(Lists, __NewTopXMLNS, 'encode_privacy_$default'(Default, __NewTopXMLNS, 'encode_privacy_$active'(Active, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. 'encode_privacy_$lists'([], __TopXMLNS, _acc) -> _acc; 'encode_privacy_$lists'([Lists | _els], __TopXMLNS, _acc) -> 'encode_privacy_$lists'(_els, __TopXMLNS, [encode_privacy_list(Lists, __TopXMLNS) | _acc]). 'encode_privacy_$default'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_privacy_$default'(Default, __TopXMLNS, _acc) -> [encode_privacy_default_list(Default, __TopXMLNS) | _acc]. 'encode_privacy_$active'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_privacy_$active'(Active, __TopXMLNS, _acc) -> [encode_privacy_active_list(Active, __TopXMLNS) | _acc]. decode_privacy_active_list(__TopXMLNS, __Opts, {xmlel, <<"active">>, _attrs, _els}) -> Name = decode_privacy_active_list_attrs(__TopXMLNS, _attrs, undefined), Name. decode_privacy_active_list_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name) -> decode_privacy_active_list_attrs(__TopXMLNS, _attrs, _val); decode_privacy_active_list_attrs(__TopXMLNS, [_ | _attrs], Name) -> decode_privacy_active_list_attrs(__TopXMLNS, _attrs, Name); decode_privacy_active_list_attrs(__TopXMLNS, [], Name) -> decode_privacy_active_list_attr_name(__TopXMLNS, Name). encode_privacy_active_list(Name, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = [], _attrs = encode_privacy_active_list_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"active">>, _attrs, _els}. decode_privacy_active_list_attr_name(__TopXMLNS, undefined) -> none; decode_privacy_active_list_attr_name(__TopXMLNS, _val) -> _val. encode_privacy_active_list_attr_name(none, _acc) -> _acc; encode_privacy_active_list_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_privacy_default_list(__TopXMLNS, __Opts, {xmlel, <<"default">>, _attrs, _els}) -> Name = decode_privacy_default_list_attrs(__TopXMLNS, _attrs, undefined), Name. decode_privacy_default_list_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name) -> decode_privacy_default_list_attrs(__TopXMLNS, _attrs, _val); decode_privacy_default_list_attrs(__TopXMLNS, [_ | _attrs], Name) -> decode_privacy_default_list_attrs(__TopXMLNS, _attrs, Name); decode_privacy_default_list_attrs(__TopXMLNS, [], Name) -> decode_privacy_default_list_attr_name(__TopXMLNS, Name). encode_privacy_default_list(Name, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = [], _attrs = encode_privacy_default_list_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"default">>, _attrs, _els}. decode_privacy_default_list_attr_name(__TopXMLNS, undefined) -> none; decode_privacy_default_list_attr_name(__TopXMLNS, _val) -> _val. encode_privacy_default_list_attr_name(none, _acc) -> _acc; encode_privacy_default_list_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_privacy_list(__TopXMLNS, __Opts, {xmlel, <<"list">>, _attrs, _els}) -> Items = decode_privacy_list_els(__TopXMLNS, __Opts, _els, []), Name = decode_privacy_list_attrs(__TopXMLNS, _attrs, undefined), {privacy_list, Name, Items}. decode_privacy_list_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_privacy_list_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_list_els(__TopXMLNS, __Opts, _els, [decode_privacy_item(<<"jabber:iq:privacy">>, __Opts, _el) | Items]); _ -> decode_privacy_list_els(__TopXMLNS, __Opts, _els, Items) end; decode_privacy_list_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_privacy_list_els(__TopXMLNS, __Opts, _els, Items). decode_privacy_list_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name) -> decode_privacy_list_attrs(__TopXMLNS, _attrs, _val); decode_privacy_list_attrs(__TopXMLNS, [_ | _attrs], Name) -> decode_privacy_list_attrs(__TopXMLNS, _attrs, Name); decode_privacy_list_attrs(__TopXMLNS, [], Name) -> decode_privacy_list_attr_name(__TopXMLNS, Name). encode_privacy_list({privacy_list, Name, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = lists:reverse('encode_privacy_list_$items'(Items, __NewTopXMLNS, [])), _attrs = encode_privacy_list_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"list">>, _attrs, _els}. 'encode_privacy_list_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_privacy_list_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_privacy_list_$items'(_els, __TopXMLNS, [encode_privacy_item(Items, __TopXMLNS) | _acc]). decode_privacy_list_attr_name(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"name">>, <<"list">>, __TopXMLNS}}); decode_privacy_list_attr_name(__TopXMLNS, _val) -> _val. encode_privacy_list_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_privacy_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> {Iq, Presence_out, Message, Presence_in} = decode_privacy_item_els(__TopXMLNS, __Opts, _els, false, false, false, false), {Action, Order, Type, Value} = decode_privacy_item_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {privacy_item, Order, Action, Type, Value, Message, Iq, Presence_in, Presence_out}. decode_privacy_item_els(__TopXMLNS, __Opts, [], Iq, Presence_out, Message, Presence_in) -> {Iq, Presence_out, Message, Presence_in}; decode_privacy_item_els(__TopXMLNS, __Opts, [{xmlel, <<"message">>, _attrs, _} = _el | _els], Iq, Presence_out, Message, Presence_in) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, Presence_out, decode_privacy_message(<<"jabber:iq:privacy">>, __Opts, _el), Presence_in); _ -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, Presence_out, Message, Presence_in) end; decode_privacy_item_els(__TopXMLNS, __Opts, [{xmlel, <<"iq">>, _attrs, _} = _el | _els], Iq, Presence_out, Message, Presence_in) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, decode_privacy_iq(<<"jabber:iq:privacy">>, __Opts, _el), Presence_out, Message, Presence_in); _ -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, Presence_out, Message, Presence_in) end; decode_privacy_item_els(__TopXMLNS, __Opts, [{xmlel, <<"presence-in">>, _attrs, _} = _el | _els], Iq, Presence_out, Message, Presence_in) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, Presence_out, Message, decode_privacy_presence_in(<<"jabber:iq:privacy">>, __Opts, _el)); _ -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, Presence_out, Message, Presence_in) end; decode_privacy_item_els(__TopXMLNS, __Opts, [{xmlel, <<"presence-out">>, _attrs, _} = _el | _els], Iq, Presence_out, Message, Presence_in) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:privacy">> -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, decode_privacy_presence_out(<<"jabber:iq:privacy">>, __Opts, _el), Message, Presence_in); _ -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, Presence_out, Message, Presence_in) end; decode_privacy_item_els(__TopXMLNS, __Opts, [_ | _els], Iq, Presence_out, Message, Presence_in) -> decode_privacy_item_els(__TopXMLNS, __Opts, _els, Iq, Presence_out, Message, Presence_in). decode_privacy_item_attrs(__TopXMLNS, [{<<"action">>, _val} | _attrs], _Action, Order, Type, Value) -> decode_privacy_item_attrs(__TopXMLNS, _attrs, _val, Order, Type, Value); decode_privacy_item_attrs(__TopXMLNS, [{<<"order">>, _val} | _attrs], Action, _Order, Type, Value) -> decode_privacy_item_attrs(__TopXMLNS, _attrs, Action, _val, Type, Value); decode_privacy_item_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Action, Order, _Type, Value) -> decode_privacy_item_attrs(__TopXMLNS, _attrs, Action, Order, _val, Value); decode_privacy_item_attrs(__TopXMLNS, [{<<"value">>, _val} | _attrs], Action, Order, Type, _Value) -> decode_privacy_item_attrs(__TopXMLNS, _attrs, Action, Order, Type, _val); decode_privacy_item_attrs(__TopXMLNS, [_ | _attrs], Action, Order, Type, Value) -> decode_privacy_item_attrs(__TopXMLNS, _attrs, Action, Order, Type, Value); decode_privacy_item_attrs(__TopXMLNS, [], Action, Order, Type, Value) -> {decode_privacy_item_attr_action(__TopXMLNS, Action), decode_privacy_item_attr_order(__TopXMLNS, Order), decode_privacy_item_attr_type(__TopXMLNS, Type), decode_privacy_item_attr_value(__TopXMLNS, Value)}. encode_privacy_item({privacy_item, Order, Action, Type, Value, Message, Iq, Presence_in, Presence_out}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = lists:reverse('encode_privacy_item_$iq'(Iq, __NewTopXMLNS, 'encode_privacy_item_$presence_out'(Presence_out, __NewTopXMLNS, 'encode_privacy_item_$message'(Message, __NewTopXMLNS, 'encode_privacy_item_$presence_in'(Presence_in, __NewTopXMLNS, []))))), _attrs = encode_privacy_item_attr_value(Value, encode_privacy_item_attr_type(Type, encode_privacy_item_attr_order(Order, encode_privacy_item_attr_action(Action, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"item">>, _attrs, _els}. 'encode_privacy_item_$iq'(false, __TopXMLNS, _acc) -> _acc; 'encode_privacy_item_$iq'(Iq, __TopXMLNS, _acc) -> [encode_privacy_iq(Iq, __TopXMLNS) | _acc]. 'encode_privacy_item_$presence_out'(false, __TopXMLNS, _acc) -> _acc; 'encode_privacy_item_$presence_out'(Presence_out, __TopXMLNS, _acc) -> [encode_privacy_presence_out(Presence_out, __TopXMLNS) | _acc]. 'encode_privacy_item_$message'(false, __TopXMLNS, _acc) -> _acc; 'encode_privacy_item_$message'(Message, __TopXMLNS, _acc) -> [encode_privacy_message(Message, __TopXMLNS) | _acc]. 'encode_privacy_item_$presence_in'(false, __TopXMLNS, _acc) -> _acc; 'encode_privacy_item_$presence_in'(Presence_in, __TopXMLNS, _acc) -> [encode_privacy_presence_in(Presence_in, __TopXMLNS) | _acc]. decode_privacy_item_attr_action(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"action">>, <<"item">>, __TopXMLNS}}); decode_privacy_item_attr_action(__TopXMLNS, _val) -> case catch dec_enum(_val, [allow, deny]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"action">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_privacy_item_attr_action(_val, _acc) -> [{<<"action">>, enc_enum(_val)} | _acc]. decode_privacy_item_attr_order(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"order">>, <<"item">>, __TopXMLNS}}); decode_privacy_item_attr_order(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"order">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_privacy_item_attr_order(_val, _acc) -> [{<<"order">>, enc_int(_val)} | _acc]. decode_privacy_item_attr_type(__TopXMLNS, undefined) -> undefined; decode_privacy_item_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [group, jid, subscription]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_privacy_item_attr_type(undefined, _acc) -> _acc; encode_privacy_item_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_privacy_item_attr_value(__TopXMLNS, undefined) -> <<>>; decode_privacy_item_attr_value(__TopXMLNS, _val) -> _val. encode_privacy_item_attr_value(<<>>, _acc) -> _acc; encode_privacy_item_attr_value(_val, _acc) -> [{<<"value">>, _val} | _acc]. decode_privacy_presence_out(__TopXMLNS, __Opts, {xmlel, <<"presence-out">>, _attrs, _els}) -> true. encode_privacy_presence_out(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"presence-out">>, _attrs, _els}. decode_privacy_presence_in(__TopXMLNS, __Opts, {xmlel, <<"presence-in">>, _attrs, _els}) -> true. encode_privacy_presence_in(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"presence-in">>, _attrs, _els}. decode_privacy_iq(__TopXMLNS, __Opts, {xmlel, <<"iq">>, _attrs, _els}) -> true. encode_privacy_iq(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"iq">>, _attrs, _els}. decode_privacy_message(__TopXMLNS, __Opts, {xmlel, <<"message">>, _attrs, _els}) -> true. encode_privacy_message(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:privacy">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"message">>, _attrs, _els}. xmpp-1.4.4/src/xep0048.erl0000644000232200023220000003447713610066730015476 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0048). -compile(export_all). do_decode(<<"storage">>, <<"storage:bookmarks">>, El, Opts) -> decode_bookmarks_storage(<<"storage:bookmarks">>, Opts, El); do_decode(<<"url">>, <<"storage:bookmarks">>, El, Opts) -> decode_bookmark_url(<<"storage:bookmarks">>, Opts, El); do_decode(<<"conference">>, <<"storage:bookmarks">>, El, Opts) -> decode_bookmark_conference(<<"storage:bookmarks">>, Opts, El); do_decode(<<"password">>, <<"storage:bookmarks">>, El, Opts) -> decode_conference_password(<<"storage:bookmarks">>, Opts, El); do_decode(<<"nick">>, <<"storage:bookmarks">>, El, Opts) -> decode_conference_nick(<<"storage:bookmarks">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"storage">>, <<"storage:bookmarks">>}, {<<"url">>, <<"storage:bookmarks">>}, {<<"conference">>, <<"storage:bookmarks">>}, {<<"password">>, <<"storage:bookmarks">>}, {<<"nick">>, <<"storage:bookmarks">>}]. do_encode({bookmark_conference, _, _, _, _, _} = Conference, TopXMLNS) -> encode_bookmark_conference(Conference, TopXMLNS); do_encode({bookmark_url, _, _} = Url, TopXMLNS) -> encode_bookmark_url(Url, TopXMLNS); do_encode({bookmark_storage, _, _} = Storage, TopXMLNS) -> encode_bookmarks_storage(Storage, TopXMLNS). do_get_name({bookmark_conference, _, _, _, _, _}) -> <<"conference">>; do_get_name({bookmark_storage, _, _}) -> <<"storage">>; do_get_name({bookmark_url, _, _}) -> <<"url">>. do_get_ns({bookmark_conference, _, _, _, _, _}) -> <<"storage:bookmarks">>; do_get_ns({bookmark_storage, _, _}) -> <<"storage:bookmarks">>; do_get_ns({bookmark_url, _, _}) -> <<"storage:bookmarks">>. pp(bookmark_conference, 5) -> [name, jid, autojoin, nick, password]; pp(bookmark_url, 2) -> [name, url]; pp(bookmark_storage, 2) -> [conference, url]; pp(_, _) -> no. records() -> [{bookmark_conference, 5}, {bookmark_url, 2}, {bookmark_storage, 2}]. dec_bool(<<"false">>) -> false; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"1">>) -> true. enc_bool(false) -> <<"false">>; enc_bool(true) -> <<"true">>. decode_bookmarks_storage(__TopXMLNS, __Opts, {xmlel, <<"storage">>, _attrs, _els}) -> {Conference, Url} = decode_bookmarks_storage_els(__TopXMLNS, __Opts, _els, [], []), {bookmark_storage, Conference, Url}. decode_bookmarks_storage_els(__TopXMLNS, __Opts, [], Conference, Url) -> {lists:reverse(Conference), lists:reverse(Url)}; decode_bookmarks_storage_els(__TopXMLNS, __Opts, [{xmlel, <<"conference">>, _attrs, _} = _el | _els], Conference, Url) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"storage:bookmarks">> -> decode_bookmarks_storage_els(__TopXMLNS, __Opts, _els, [decode_bookmark_conference(<<"storage:bookmarks">>, __Opts, _el) | Conference], Url); _ -> decode_bookmarks_storage_els(__TopXMLNS, __Opts, _els, Conference, Url) end; decode_bookmarks_storage_els(__TopXMLNS, __Opts, [{xmlel, <<"url">>, _attrs, _} = _el | _els], Conference, Url) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"storage:bookmarks">> -> decode_bookmarks_storage_els(__TopXMLNS, __Opts, _els, Conference, [decode_bookmark_url(<<"storage:bookmarks">>, __Opts, _el) | Url]); _ -> decode_bookmarks_storage_els(__TopXMLNS, __Opts, _els, Conference, Url) end; decode_bookmarks_storage_els(__TopXMLNS, __Opts, [_ | _els], Conference, Url) -> decode_bookmarks_storage_els(__TopXMLNS, __Opts, _els, Conference, Url). encode_bookmarks_storage({bookmark_storage, Conference, Url}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"storage:bookmarks">>, [], __TopXMLNS), _els = lists:reverse('encode_bookmarks_storage_$conference'(Conference, __NewTopXMLNS, 'encode_bookmarks_storage_$url'(Url, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"storage">>, _attrs, _els}. 'encode_bookmarks_storage_$conference'([], __TopXMLNS, _acc) -> _acc; 'encode_bookmarks_storage_$conference'([Conference | _els], __TopXMLNS, _acc) -> 'encode_bookmarks_storage_$conference'(_els, __TopXMLNS, [encode_bookmark_conference(Conference, __TopXMLNS) | _acc]). 'encode_bookmarks_storage_$url'([], __TopXMLNS, _acc) -> _acc; 'encode_bookmarks_storage_$url'([Url | _els], __TopXMLNS, _acc) -> 'encode_bookmarks_storage_$url'(_els, __TopXMLNS, [encode_bookmark_url(Url, __TopXMLNS) | _acc]). decode_bookmark_url(__TopXMLNS, __Opts, {xmlel, <<"url">>, _attrs, _els}) -> {Name, Url} = decode_bookmark_url_attrs(__TopXMLNS, _attrs, undefined, undefined), {bookmark_url, Name, Url}. decode_bookmark_url_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name, Url) -> decode_bookmark_url_attrs(__TopXMLNS, _attrs, _val, Url); decode_bookmark_url_attrs(__TopXMLNS, [{<<"url">>, _val} | _attrs], Name, _Url) -> decode_bookmark_url_attrs(__TopXMLNS, _attrs, Name, _val); decode_bookmark_url_attrs(__TopXMLNS, [_ | _attrs], Name, Url) -> decode_bookmark_url_attrs(__TopXMLNS, _attrs, Name, Url); decode_bookmark_url_attrs(__TopXMLNS, [], Name, Url) -> {decode_bookmark_url_attr_name(__TopXMLNS, Name), decode_bookmark_url_attr_url(__TopXMLNS, Url)}. encode_bookmark_url({bookmark_url, Name, Url}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"storage:bookmarks">>, [], __TopXMLNS), _els = [], _attrs = encode_bookmark_url_attr_url(Url, encode_bookmark_url_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"url">>, _attrs, _els}. decode_bookmark_url_attr_name(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"name">>, <<"url">>, __TopXMLNS}}); decode_bookmark_url_attr_name(__TopXMLNS, _val) -> _val. encode_bookmark_url_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_bookmark_url_attr_url(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"url">>, <<"url">>, __TopXMLNS}}); decode_bookmark_url_attr_url(__TopXMLNS, _val) -> _val. encode_bookmark_url_attr_url(_val, _acc) -> [{<<"url">>, _val} | _acc]. decode_bookmark_conference(__TopXMLNS, __Opts, {xmlel, <<"conference">>, _attrs, _els}) -> {Password, Nick} = decode_bookmark_conference_els(__TopXMLNS, __Opts, _els, undefined, undefined), {Name, Jid, Autojoin} = decode_bookmark_conference_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {bookmark_conference, Name, Jid, Autojoin, Nick, Password}. decode_bookmark_conference_els(__TopXMLNS, __Opts, [], Password, Nick) -> {Password, Nick}; decode_bookmark_conference_els(__TopXMLNS, __Opts, [{xmlel, <<"nick">>, _attrs, _} = _el | _els], Password, Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"storage:bookmarks">> -> decode_bookmark_conference_els(__TopXMLNS, __Opts, _els, Password, decode_conference_nick(<<"storage:bookmarks">>, __Opts, _el)); _ -> decode_bookmark_conference_els(__TopXMLNS, __Opts, _els, Password, Nick) end; decode_bookmark_conference_els(__TopXMLNS, __Opts, [{xmlel, <<"password">>, _attrs, _} = _el | _els], Password, Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"storage:bookmarks">> -> decode_bookmark_conference_els(__TopXMLNS, __Opts, _els, decode_conference_password(<<"storage:bookmarks">>, __Opts, _el), Nick); _ -> decode_bookmark_conference_els(__TopXMLNS, __Opts, _els, Password, Nick) end; decode_bookmark_conference_els(__TopXMLNS, __Opts, [_ | _els], Password, Nick) -> decode_bookmark_conference_els(__TopXMLNS, __Opts, _els, Password, Nick). decode_bookmark_conference_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name, Jid, Autojoin) -> decode_bookmark_conference_attrs(__TopXMLNS, _attrs, _val, Jid, Autojoin); decode_bookmark_conference_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Name, _Jid, Autojoin) -> decode_bookmark_conference_attrs(__TopXMLNS, _attrs, Name, _val, Autojoin); decode_bookmark_conference_attrs(__TopXMLNS, [{<<"autojoin">>, _val} | _attrs], Name, Jid, _Autojoin) -> decode_bookmark_conference_attrs(__TopXMLNS, _attrs, Name, Jid, _val); decode_bookmark_conference_attrs(__TopXMLNS, [_ | _attrs], Name, Jid, Autojoin) -> decode_bookmark_conference_attrs(__TopXMLNS, _attrs, Name, Jid, Autojoin); decode_bookmark_conference_attrs(__TopXMLNS, [], Name, Jid, Autojoin) -> {decode_bookmark_conference_attr_name(__TopXMLNS, Name), decode_bookmark_conference_attr_jid(__TopXMLNS, Jid), decode_bookmark_conference_attr_autojoin(__TopXMLNS, Autojoin)}. encode_bookmark_conference({bookmark_conference, Name, Jid, Autojoin, Nick, Password}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"storage:bookmarks">>, [], __TopXMLNS), _els = lists:reverse('encode_bookmark_conference_$password'(Password, __NewTopXMLNS, 'encode_bookmark_conference_$nick'(Nick, __NewTopXMLNS, []))), _attrs = encode_bookmark_conference_attr_autojoin(Autojoin, encode_bookmark_conference_attr_jid(Jid, encode_bookmark_conference_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"conference">>, _attrs, _els}. 'encode_bookmark_conference_$password'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_bookmark_conference_$password'(Password, __TopXMLNS, _acc) -> [encode_conference_password(Password, __TopXMLNS) | _acc]. 'encode_bookmark_conference_$nick'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_bookmark_conference_$nick'(Nick, __TopXMLNS, _acc) -> [encode_conference_nick(Nick, __TopXMLNS) | _acc]. decode_bookmark_conference_attr_name(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"name">>, <<"conference">>, __TopXMLNS}}); decode_bookmark_conference_attr_name(__TopXMLNS, _val) -> _val. encode_bookmark_conference_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_bookmark_conference_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"conference">>, __TopXMLNS}}); decode_bookmark_conference_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"conference">>, __TopXMLNS}}); _res -> _res end. encode_bookmark_conference_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_bookmark_conference_attr_autojoin(__TopXMLNS, undefined) -> false; decode_bookmark_conference_attr_autojoin(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"autojoin">>, <<"conference">>, __TopXMLNS}}); _res -> _res end. encode_bookmark_conference_attr_autojoin(false, _acc) -> _acc; encode_bookmark_conference_attr_autojoin(_val, _acc) -> [{<<"autojoin">>, enc_bool(_val)} | _acc]. decode_conference_password(__TopXMLNS, __Opts, {xmlel, <<"password">>, _attrs, _els}) -> Cdata = decode_conference_password_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_conference_password_els(__TopXMLNS, __Opts, [], Cdata) -> decode_conference_password_cdata(__TopXMLNS, Cdata); decode_conference_password_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_conference_password_els(__TopXMLNS, __Opts, _els, <>); decode_conference_password_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_conference_password_els(__TopXMLNS, __Opts, _els, Cdata). encode_conference_password(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"storage:bookmarks">>, [], __TopXMLNS), _els = encode_conference_password_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"password">>, _attrs, _els}. decode_conference_password_cdata(__TopXMLNS, <<>>) -> <<>>; decode_conference_password_cdata(__TopXMLNS, _val) -> _val. encode_conference_password_cdata(<<>>, _acc) -> _acc; encode_conference_password_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_conference_nick(__TopXMLNS, __Opts, {xmlel, <<"nick">>, _attrs, _els}) -> Cdata = decode_conference_nick_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_conference_nick_els(__TopXMLNS, __Opts, [], Cdata) -> decode_conference_nick_cdata(__TopXMLNS, Cdata); decode_conference_nick_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_conference_nick_els(__TopXMLNS, __Opts, _els, <>); decode_conference_nick_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_conference_nick_els(__TopXMLNS, __Opts, _els, Cdata). encode_conference_nick(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"storage:bookmarks">>, [], __TopXMLNS), _els = encode_conference_nick_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"nick">>, _attrs, _els}. decode_conference_nick_cdata(__TopXMLNS, <<>>) -> <<>>; decode_conference_nick_cdata(__TopXMLNS, _val) -> _val. encode_conference_nick_cdata(<<>>, _acc) -> _acc; encode_conference_nick_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0059.erl0000644000232200023220000004473513610066730015476 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0059). -compile(export_all). do_decode(<<"set">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_set(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(<<"first">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_first(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(<<"max">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_max(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(<<"index">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_index(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(<<"count">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_count(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(<<"last">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_last(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(<<"before">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_before(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(<<"after">>, <<"http://jabber.org/protocol/rsm">>, El, Opts) -> decode_rsm_after(<<"http://jabber.org/protocol/rsm">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"set">>, <<"http://jabber.org/protocol/rsm">>}, {<<"first">>, <<"http://jabber.org/protocol/rsm">>}, {<<"max">>, <<"http://jabber.org/protocol/rsm">>}, {<<"index">>, <<"http://jabber.org/protocol/rsm">>}, {<<"count">>, <<"http://jabber.org/protocol/rsm">>}, {<<"last">>, <<"http://jabber.org/protocol/rsm">>}, {<<"before">>, <<"http://jabber.org/protocol/rsm">>}, {<<"after">>, <<"http://jabber.org/protocol/rsm">>}]. do_encode({rsm_first, _, _} = First, TopXMLNS) -> encode_rsm_first(First, TopXMLNS); do_encode({rsm_set, _, _, _, _, _, _, _} = Set, TopXMLNS) -> encode_rsm_set(Set, TopXMLNS). do_get_name({rsm_first, _, _}) -> <<"first">>; do_get_name({rsm_set, _, _, _, _, _, _, _}) -> <<"set">>. do_get_ns({rsm_first, _, _}) -> <<"http://jabber.org/protocol/rsm">>; do_get_ns({rsm_set, _, _, _, _, _, _, _}) -> <<"http://jabber.org/protocol/rsm">>. pp(rsm_first, 2) -> [index, data]; pp(rsm_set, 7) -> ['after', before, count, first, index, last, max]; pp(_, _) -> no. records() -> [{rsm_first, 2}, {rsm_set, 7}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_rsm_set(__TopXMLNS, __Opts, {xmlel, <<"set">>, _attrs, _els}) -> {After, Last, First, Count, Before, Max, Index} = decode_rsm_set_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined, undefined, undefined, undefined), {rsm_set, After, Before, Count, First, Index, Last, Max}. decode_rsm_set_els(__TopXMLNS, __Opts, [], After, Last, First, Count, Before, Max, Index) -> {After, Last, First, Count, Before, Max, Index}; decode_rsm_set_els(__TopXMLNS, __Opts, [{xmlel, <<"after">>, _attrs, _} = _el | _els], After, Last, First, Count, Before, Max, Index) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, decode_rsm_after(<<"http://jabber.org/protocol/rsm">>, __Opts, _el), Last, First, Count, Before, Max, Index); _ -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index) end; decode_rsm_set_els(__TopXMLNS, __Opts, [{xmlel, <<"before">>, _attrs, _} = _el | _els], After, Last, First, Count, Before, Max, Index) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, decode_rsm_before(<<"http://jabber.org/protocol/rsm">>, __Opts, _el), Max, Index); _ -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index) end; decode_rsm_set_els(__TopXMLNS, __Opts, [{xmlel, <<"count">>, _attrs, _} = _el | _els], After, Last, First, Count, Before, Max, Index) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, decode_rsm_count(<<"http://jabber.org/protocol/rsm">>, __Opts, _el), Before, Max, Index); _ -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index) end; decode_rsm_set_els(__TopXMLNS, __Opts, [{xmlel, <<"first">>, _attrs, _} = _el | _els], After, Last, First, Count, Before, Max, Index) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, decode_rsm_first(<<"http://jabber.org/protocol/rsm">>, __Opts, _el), Count, Before, Max, Index); _ -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index) end; decode_rsm_set_els(__TopXMLNS, __Opts, [{xmlel, <<"index">>, _attrs, _} = _el | _els], After, Last, First, Count, Before, Max, Index) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, decode_rsm_index(<<"http://jabber.org/protocol/rsm">>, __Opts, _el)); _ -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index) end; decode_rsm_set_els(__TopXMLNS, __Opts, [{xmlel, <<"last">>, _attrs, _} = _el | _els], After, Last, First, Count, Before, Max, Index) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, decode_rsm_last(<<"http://jabber.org/protocol/rsm">>, __Opts, _el), First, Count, Before, Max, Index); _ -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index) end; decode_rsm_set_els(__TopXMLNS, __Opts, [{xmlel, <<"max">>, _attrs, _} = _el | _els], After, Last, First, Count, Before, Max, Index) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, decode_rsm_max(<<"http://jabber.org/protocol/rsm">>, __Opts, _el), Index); _ -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index) end; decode_rsm_set_els(__TopXMLNS, __Opts, [_ | _els], After, Last, First, Count, Before, Max, Index) -> decode_rsm_set_els(__TopXMLNS, __Opts, _els, After, Last, First, Count, Before, Max, Index). encode_rsm_set({rsm_set, After, Before, Count, First, Index, Last, Max}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = lists:reverse('encode_rsm_set_$after'(After, __NewTopXMLNS, 'encode_rsm_set_$last'(Last, __NewTopXMLNS, 'encode_rsm_set_$first'(First, __NewTopXMLNS, 'encode_rsm_set_$count'(Count, __NewTopXMLNS, 'encode_rsm_set_$before'(Before, __NewTopXMLNS, 'encode_rsm_set_$max'(Max, __NewTopXMLNS, 'encode_rsm_set_$index'(Index, __NewTopXMLNS, [])))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"set">>, _attrs, _els}. 'encode_rsm_set_$after'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_rsm_set_$after'(After, __TopXMLNS, _acc) -> [encode_rsm_after(After, __TopXMLNS) | _acc]. 'encode_rsm_set_$last'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_rsm_set_$last'(Last, __TopXMLNS, _acc) -> [encode_rsm_last(Last, __TopXMLNS) | _acc]. 'encode_rsm_set_$first'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_rsm_set_$first'(First, __TopXMLNS, _acc) -> [encode_rsm_first(First, __TopXMLNS) | _acc]. 'encode_rsm_set_$count'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_rsm_set_$count'(Count, __TopXMLNS, _acc) -> [encode_rsm_count(Count, __TopXMLNS) | _acc]. 'encode_rsm_set_$before'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_rsm_set_$before'(Before, __TopXMLNS, _acc) -> [encode_rsm_before(Before, __TopXMLNS) | _acc]. 'encode_rsm_set_$max'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_rsm_set_$max'(Max, __TopXMLNS, _acc) -> [encode_rsm_max(Max, __TopXMLNS) | _acc]. 'encode_rsm_set_$index'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_rsm_set_$index'(Index, __TopXMLNS, _acc) -> [encode_rsm_index(Index, __TopXMLNS) | _acc]. decode_rsm_first(__TopXMLNS, __Opts, {xmlel, <<"first">>, _attrs, _els}) -> Data = decode_rsm_first_els(__TopXMLNS, __Opts, _els, <<>>), Index = decode_rsm_first_attrs(__TopXMLNS, _attrs, undefined), {rsm_first, Index, Data}. decode_rsm_first_els(__TopXMLNS, __Opts, [], Data) -> decode_rsm_first_cdata(__TopXMLNS, Data); decode_rsm_first_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_rsm_first_els(__TopXMLNS, __Opts, _els, <>); decode_rsm_first_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_rsm_first_els(__TopXMLNS, __Opts, _els, Data). decode_rsm_first_attrs(__TopXMLNS, [{<<"index">>, _val} | _attrs], _Index) -> decode_rsm_first_attrs(__TopXMLNS, _attrs, _val); decode_rsm_first_attrs(__TopXMLNS, [_ | _attrs], Index) -> decode_rsm_first_attrs(__TopXMLNS, _attrs, Index); decode_rsm_first_attrs(__TopXMLNS, [], Index) -> decode_rsm_first_attr_index(__TopXMLNS, Index). encode_rsm_first({rsm_first, Index, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = encode_rsm_first_cdata(Data, []), _attrs = encode_rsm_first_attr_index(Index, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"first">>, _attrs, _els}. decode_rsm_first_attr_index(__TopXMLNS, undefined) -> undefined; decode_rsm_first_attr_index(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"index">>, <<"first">>, __TopXMLNS}}); _res -> _res end. encode_rsm_first_attr_index(undefined, _acc) -> _acc; encode_rsm_first_attr_index(_val, _acc) -> [{<<"index">>, enc_int(_val)} | _acc]. decode_rsm_first_cdata(__TopXMLNS, <<>>) -> <<>>; decode_rsm_first_cdata(__TopXMLNS, _val) -> _val. encode_rsm_first_cdata(<<>>, _acc) -> _acc; encode_rsm_first_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_rsm_max(__TopXMLNS, __Opts, {xmlel, <<"max">>, _attrs, _els}) -> Cdata = decode_rsm_max_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_rsm_max_els(__TopXMLNS, __Opts, [], Cdata) -> decode_rsm_max_cdata(__TopXMLNS, Cdata); decode_rsm_max_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_rsm_max_els(__TopXMLNS, __Opts, _els, <>); decode_rsm_max_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_rsm_max_els(__TopXMLNS, __Opts, _els, Cdata). encode_rsm_max(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = encode_rsm_max_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"max">>, _attrs, _els}. decode_rsm_max_cdata(__TopXMLNS, <<>>) -> undefined; decode_rsm_max_cdata(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"max">>, __TopXMLNS}}); _res -> _res end. encode_rsm_max_cdata(undefined, _acc) -> _acc; encode_rsm_max_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_rsm_index(__TopXMLNS, __Opts, {xmlel, <<"index">>, _attrs, _els}) -> Cdata = decode_rsm_index_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_rsm_index_els(__TopXMLNS, __Opts, [], Cdata) -> decode_rsm_index_cdata(__TopXMLNS, Cdata); decode_rsm_index_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_rsm_index_els(__TopXMLNS, __Opts, _els, <>); decode_rsm_index_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_rsm_index_els(__TopXMLNS, __Opts, _els, Cdata). encode_rsm_index(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = encode_rsm_index_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"index">>, _attrs, _els}. decode_rsm_index_cdata(__TopXMLNS, <<>>) -> undefined; decode_rsm_index_cdata(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"index">>, __TopXMLNS}}); _res -> _res end. encode_rsm_index_cdata(undefined, _acc) -> _acc; encode_rsm_index_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_rsm_count(__TopXMLNS, __Opts, {xmlel, <<"count">>, _attrs, _els}) -> Cdata = decode_rsm_count_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_rsm_count_els(__TopXMLNS, __Opts, [], Cdata) -> decode_rsm_count_cdata(__TopXMLNS, Cdata); decode_rsm_count_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_rsm_count_els(__TopXMLNS, __Opts, _els, <>); decode_rsm_count_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_rsm_count_els(__TopXMLNS, __Opts, _els, Cdata). encode_rsm_count(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = encode_rsm_count_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"count">>, _attrs, _els}. decode_rsm_count_cdata(__TopXMLNS, <<>>) -> undefined; decode_rsm_count_cdata(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"count">>, __TopXMLNS}}); _res -> _res end. encode_rsm_count_cdata(undefined, _acc) -> _acc; encode_rsm_count_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_rsm_last(__TopXMLNS, __Opts, {xmlel, <<"last">>, _attrs, _els}) -> Cdata = decode_rsm_last_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_rsm_last_els(__TopXMLNS, __Opts, [], Cdata) -> decode_rsm_last_cdata(__TopXMLNS, Cdata); decode_rsm_last_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_rsm_last_els(__TopXMLNS, __Opts, _els, <>); decode_rsm_last_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_rsm_last_els(__TopXMLNS, __Opts, _els, Cdata). encode_rsm_last(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = encode_rsm_last_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"last">>, _attrs, _els}. decode_rsm_last_cdata(__TopXMLNS, <<>>) -> <<>>; decode_rsm_last_cdata(__TopXMLNS, _val) -> _val. encode_rsm_last_cdata(<<>>, _acc) -> _acc; encode_rsm_last_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_rsm_before(__TopXMLNS, __Opts, {xmlel, <<"before">>, _attrs, _els}) -> Cdata = decode_rsm_before_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_rsm_before_els(__TopXMLNS, __Opts, [], Cdata) -> decode_rsm_before_cdata(__TopXMLNS, Cdata); decode_rsm_before_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_rsm_before_els(__TopXMLNS, __Opts, _els, <>); decode_rsm_before_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_rsm_before_els(__TopXMLNS, __Opts, _els, Cdata). encode_rsm_before(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = encode_rsm_before_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"before">>, _attrs, _els}. decode_rsm_before_cdata(__TopXMLNS, <<>>) -> <<>>; decode_rsm_before_cdata(__TopXMLNS, _val) -> _val. encode_rsm_before_cdata(<<>>, _acc) -> _acc; encode_rsm_before_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_rsm_after(__TopXMLNS, __Opts, {xmlel, <<"after">>, _attrs, _els}) -> Cdata = decode_rsm_after_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_rsm_after_els(__TopXMLNS, __Opts, [], Cdata) -> decode_rsm_after_cdata(__TopXMLNS, Cdata); decode_rsm_after_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_rsm_after_els(__TopXMLNS, __Opts, _els, <>); decode_rsm_after_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_rsm_after_els(__TopXMLNS, __Opts, _els, Cdata). encode_rsm_after(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/rsm">>, [], __TopXMLNS), _els = encode_rsm_after_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"after">>, _attrs, _els}. decode_rsm_after_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"after">>, __TopXMLNS}}); decode_rsm_after_cdata(__TopXMLNS, _val) -> _val. encode_rsm_after_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/pubsub_meta_data.erl0000644000232200023220000006162113610066730017654 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_meta_data.xdata %% Form type: http://jabber.org/protocol/pubsub#meta-data %% Document: XEP-0060 -module(pubsub_meta_data). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("pubsub_meta_data.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [contact | creation_date | creator | description | language | num_subscribers | owner | publisher | title | type | max_items | access_model | publish_model]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/pubsub#meta-data">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {contact, Val} -> [encode_contact(Val, Lang, lists:member(contact, Required))]; {creation_date, Val} -> [encode_creation_date(Val, Lang, lists:member(creation_date, Required))]; {creator, Val} -> [encode_creator(Val, Lang, lists:member(creator, Required))]; {description, Val} -> [encode_description(Val, Lang, lists:member(description, Required))]; {language, Val} -> [encode_language(Val, default, Lang, lists:member(language, Required))]; {language, Val, Opts} -> [encode_language(Val, Opts, Lang, lists:member(language, Required))]; {num_subscribers, Val} -> [encode_num_subscribers(Val, Lang, lists:member(num_subscribers, Required))]; {owner, Val} -> [encode_owner(Val, Lang, lists:member(owner, Required))]; {publisher, Val} -> [encode_publisher(Val, Lang, lists:member(publisher, Required))]; {title, Val} -> [encode_title(Val, Lang, lists:member(title, Required))]; {type, Val} -> [encode_type(Val, Lang, lists:member(type, Required))]; {max_items, Val} -> [encode_max_items(Val, Lang, lists:member(max_items, Required))]; {access_model, Val} -> [encode_access_model(Val, default, Lang, lists:member(access_model, Required))]; {access_model, Val, Opts} -> [encode_access_model(Val, Opts, Lang, lists:member(access_model, Required))]; {publish_model, Val} -> [encode_publish_model(Val, default, Lang, lists:member(publish_model, Required))]; {publish_model, Val, Opts} -> [encode_publish_model(Val, Opts, Lang, lists:member(publish_model, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/pubsub#meta-data">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"pubsub#contact">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"pubsub#contact">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#contact">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#contact">>, Required), [{contact, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#contact">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#creation_date">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try xmpp_util:decode_timestamp(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#creation_date">>, Required), [{creation_date, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#creation_date">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#creation_date">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#creation_date">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#creation_date">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#creation_date">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#creator">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try jid:decode(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#creator">>, Required), [{creator, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#creator">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#creator">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#creator">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#creator">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#creator">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#description">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#description">>, Required), [{description, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#description">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#description">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#description">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#description">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#description">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#language">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#language">>, Required), [{language, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#language">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#language">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#language">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#language">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#language">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#num_subscribers">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#num_subscribers">>, Required), [{num_subscribers, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#num_subscribers">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#num_subscribers">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#num_subscribers">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#num_subscribers">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#num_subscribers">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#owner">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"pubsub#owner">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#owner">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#owner">>, Required), [{owner, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#owner">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#publisher">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"pubsub#publisher">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#publisher">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#publisher">>, Required), [{publisher, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#publisher">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#title">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#title">>, Required), [{title, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#title">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#title">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#title">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#title">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#title">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#type">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#type">>, Required), [{type, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#type">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#type">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#type">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#type">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#type">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#max_items">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#max_items">>, Required), [{max_items, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#max_items">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#max_items">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#max_items">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#max_items">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#max_items">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#access_model">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [authorize, open, presence, roster, whitelist]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#access_model">>, Required), [{access_model, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#access_model">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#access_model">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#access_model">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#access_model">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#access_model">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#publish_model">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [publishers, subscribers, open]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#publish_model">>, Required), [{publish_model, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#publish_model">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#publish_model">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#publish_model">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#publish_model">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#publish_model">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_contact([jid:jid()], binary(), boolean()) -> xdata_field(). encode_contact(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"pubsub#contact">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The JIDs of those to contact with questions"))}. -spec encode_creation_date(erlang:timestamp() | undefined, binary(), boolean()) -> xdata_field(). encode_creation_date(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [xmpp_util:encode_timestamp(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#creation_date">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The datetime when the node was created"))}. -spec encode_creator(jid:jid() | undefined, binary(), boolean()) -> xdata_field(). encode_creator(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [jid:encode(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#creator">>, values = Values, required = IsRequired, type = 'jid-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The JID of the node creator"))}. -spec encode_description(binary(), binary(), boolean()) -> xdata_field(). encode_description(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#description">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("A description of the node"))}. -spec encode_language(binary(), default | options(binary()), binary(), boolean()) -> xdata_field(). encode_language(Value, Options, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = if Options == default -> []; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = V} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#language">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The default language of the node"))}. -spec encode_num_subscribers(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_num_subscribers(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#num_subscribers">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The number of subscribers to the node"))}. -spec encode_owner([jid:jid()], binary(), boolean()) -> xdata_field(). encode_owner(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"pubsub#owner">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The JIDs of those with an affiliation " "of owner"))}. -spec encode_publisher([jid:jid()], binary(), boolean()) -> xdata_field(). encode_publisher(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"pubsub#publisher">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The JIDs of those with an affiliation " "of publisher"))}. -spec encode_title(binary(), binary(), boolean()) -> xdata_field(). encode_title(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#title">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The name of the node"))}. -spec encode_type(binary(), binary(), boolean()) -> xdata_field(). encode_type(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#type">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Payload type"))}. -spec encode_max_items(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_max_items(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#max_items">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Maximum number of items to persist"))}. -spec encode_access_model(access_model() | undefined, default | options(access_model()), binary(), boolean()) -> xdata_field(). encode_access_model(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Subscription requests must be approved " "and only subscribers may retrieve items")), value = <<"authorize">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone may subscribe and retrieve items")), value = <<"open">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone with a presence subscription " "of both or from may subscribe and retrieve " "items")), value = <<"presence">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone in the specified roster group(s) " "may subscribe and retrieve items")), value = <<"roster">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Only those on a whitelist may subscribe " "and retrieve items")), value = <<"whitelist">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#access_model">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Access model"))}. -spec encode_publish_model(publish_model() | undefined, default | options(publish_model()), binary(), boolean()) -> xdata_field(). encode_publish_model(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Only publishers may publish")), value = <<"publishers">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Subscribers may publish")), value = <<"subscribers">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone may publish")), value = <<"open">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#publish_model">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Publish model"))}. xmpp-1.4.4/src/xep0260.erl0000644000232200023220000005322013610066730015455 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0260). -compile(export_all). do_decode(<<"transport">>, <<"urn:xmpp:jingle:transports:s5b:1">>, El, Opts) -> decode_jingle_s5b_transport(<<"urn:xmpp:jingle:transports:s5b:1">>, Opts, El); do_decode(<<"proxy-error">>, <<"urn:xmpp:jingle:transports:s5b:1">>, El, Opts) -> decode_jingle_s5b_proxy_error(<<"urn:xmpp:jingle:transports:s5b:1">>, Opts, El); do_decode(<<"candidate-error">>, <<"urn:xmpp:jingle:transports:s5b:1">>, El, Opts) -> decode_jingle_s5b_candidate_error(<<"urn:xmpp:jingle:transports:s5b:1">>, Opts, El); do_decode(<<"activated">>, <<"urn:xmpp:jingle:transports:s5b:1">>, El, Opts) -> decode_jingle_s5b_activated(<<"urn:xmpp:jingle:transports:s5b:1">>, Opts, El); do_decode(<<"candidate">>, <<"urn:xmpp:jingle:transports:s5b:1">>, El, Opts) -> decode_jingle_s5b_candidate(<<"urn:xmpp:jingle:transports:s5b:1">>, Opts, El); do_decode(<<"candidate-used">>, <<"urn:xmpp:jingle:transports:s5b:1">>, El, Opts) -> decode_jingle_s5b_candidate_used(<<"urn:xmpp:jingle:transports:s5b:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"transport">>, <<"urn:xmpp:jingle:transports:s5b:1">>}, {<<"proxy-error">>, <<"urn:xmpp:jingle:transports:s5b:1">>}, {<<"candidate-error">>, <<"urn:xmpp:jingle:transports:s5b:1">>}, {<<"activated">>, <<"urn:xmpp:jingle:transports:s5b:1">>}, {<<"candidate">>, <<"urn:xmpp:jingle:transports:s5b:1">>}, {<<"candidate-used">>, <<"urn:xmpp:jingle:transports:s5b:1">>}]. do_encode({jingle_s5b_candidate, _, _, _, _, _, _} = Candidate, TopXMLNS) -> encode_jingle_s5b_candidate(Candidate, TopXMLNS); do_encode({jingle_s5b_transport, _, _, _, _, _, _, _} = Transport, TopXMLNS) -> encode_jingle_s5b_transport(Transport, TopXMLNS). do_get_name({jingle_s5b_candidate, _, _, _, _, _, _}) -> <<"candidate">>; do_get_name({jingle_s5b_transport, _, _, _, _, _, _, _}) -> <<"transport">>. do_get_ns({jingle_s5b_candidate, _, _, _, _, _, _}) -> <<"urn:xmpp:jingle:transports:s5b:1">>; do_get_ns({jingle_s5b_transport, _, _, _, _, _, _, _}) -> <<"urn:xmpp:jingle:transports:s5b:1">>. pp(jingle_s5b_candidate, 6) -> [cid, host, port, jid, type, priority]; pp(jingle_s5b_transport, 7) -> [sid, dstaddr, mode, candidates, 'candidate-used', activated, error]; pp(_, _) -> no. records() -> [{jingle_s5b_candidate, 6}, {jingle_s5b_transport, 7}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. dec_ip(S) -> {ok, Addr} = inet_parse:address(binary_to_list(S)), Addr. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). decode_jingle_s5b_transport(__TopXMLNS, __Opts, {xmlel, <<"transport">>, _attrs, _els}) -> {Error, Candidates, Activated, Candidate_used} = decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, undefined, [], undefined, undefined), {Sid, Dstaddr, Mode} = decode_jingle_s5b_transport_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {jingle_s5b_transport, Sid, Dstaddr, Mode, Candidates, Candidate_used, Activated, Error}. decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, [], Error, Candidates, Activated, Candidate_used) -> {Error, lists:reverse(Candidates), Activated, Candidate_used}; decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, [{xmlel, <<"candidate">>, _attrs, _} = _el | _els], Error, Candidates, Activated, Candidate_used) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:transports:s5b:1">> -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, [decode_jingle_s5b_candidate(<<"urn:xmpp:jingle:transports:s5b:1">>, __Opts, _el) | Candidates], Activated, Candidate_used); _ -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, Activated, Candidate_used) end; decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, [{xmlel, <<"candidate-used">>, _attrs, _} = _el | _els], Error, Candidates, Activated, Candidate_used) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:transports:s5b:1">> -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, Activated, decode_jingle_s5b_candidate_used(<<"urn:xmpp:jingle:transports:s5b:1">>, __Opts, _el)); _ -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, Activated, Candidate_used) end; decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, [{xmlel, <<"activated">>, _attrs, _} = _el | _els], Error, Candidates, Activated, Candidate_used) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:transports:s5b:1">> -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, decode_jingle_s5b_activated(<<"urn:xmpp:jingle:transports:s5b:1">>, __Opts, _el), Candidate_used); _ -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, Activated, Candidate_used) end; decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, [{xmlel, <<"candidate-error">>, _attrs, _} = _el | _els], Error, Candidates, Activated, Candidate_used) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:transports:s5b:1">> -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, decode_jingle_s5b_candidate_error(<<"urn:xmpp:jingle:transports:s5b:1">>, __Opts, _el), Candidates, Activated, Candidate_used); _ -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, Activated, Candidate_used) end; decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, [{xmlel, <<"proxy-error">>, _attrs, _} = _el | _els], Error, Candidates, Activated, Candidate_used) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:transports:s5b:1">> -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, decode_jingle_s5b_proxy_error(<<"urn:xmpp:jingle:transports:s5b:1">>, __Opts, _el), Candidates, Activated, Candidate_used); _ -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, Activated, Candidate_used) end; decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, [_ | _els], Error, Candidates, Activated, Candidate_used) -> decode_jingle_s5b_transport_els(__TopXMLNS, __Opts, _els, Error, Candidates, Activated, Candidate_used). decode_jingle_s5b_transport_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], _Sid, Dstaddr, Mode) -> decode_jingle_s5b_transport_attrs(__TopXMLNS, _attrs, _val, Dstaddr, Mode); decode_jingle_s5b_transport_attrs(__TopXMLNS, [{<<"dstaddr">>, _val} | _attrs], Sid, _Dstaddr, Mode) -> decode_jingle_s5b_transport_attrs(__TopXMLNS, _attrs, Sid, _val, Mode); decode_jingle_s5b_transport_attrs(__TopXMLNS, [{<<"mode">>, _val} | _attrs], Sid, Dstaddr, _Mode) -> decode_jingle_s5b_transport_attrs(__TopXMLNS, _attrs, Sid, Dstaddr, _val); decode_jingle_s5b_transport_attrs(__TopXMLNS, [_ | _attrs], Sid, Dstaddr, Mode) -> decode_jingle_s5b_transport_attrs(__TopXMLNS, _attrs, Sid, Dstaddr, Mode); decode_jingle_s5b_transport_attrs(__TopXMLNS, [], Sid, Dstaddr, Mode) -> {decode_jingle_s5b_transport_attr_sid(__TopXMLNS, Sid), decode_jingle_s5b_transport_attr_dstaddr(__TopXMLNS, Dstaddr), decode_jingle_s5b_transport_attr_mode(__TopXMLNS, Mode)}. encode_jingle_s5b_transport({jingle_s5b_transport, Sid, Dstaddr, Mode, Candidates, Candidate_used, Activated, Error}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:transports:s5b:1">>, [], __TopXMLNS), _els = lists:reverse('encode_jingle_s5b_transport_$error'(Error, __NewTopXMLNS, 'encode_jingle_s5b_transport_$candidates'(Candidates, __NewTopXMLNS, 'encode_jingle_s5b_transport_$activated'(Activated, __NewTopXMLNS, 'encode_jingle_s5b_transport_$candidate-used'(Candidate_used, __NewTopXMLNS, []))))), _attrs = encode_jingle_s5b_transport_attr_mode(Mode, encode_jingle_s5b_transport_attr_dstaddr(Dstaddr, encode_jingle_s5b_transport_attr_sid(Sid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"transport">>, _attrs, _els}. 'encode_jingle_s5b_transport_$error'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_s5b_transport_$error'('candidate-error' = Error, __TopXMLNS, _acc) -> [encode_jingle_s5b_candidate_error(Error, __TopXMLNS) | _acc]; 'encode_jingle_s5b_transport_$error'('proxy-error' = Error, __TopXMLNS, _acc) -> [encode_jingle_s5b_proxy_error(Error, __TopXMLNS) | _acc]. 'encode_jingle_s5b_transport_$candidates'([], __TopXMLNS, _acc) -> _acc; 'encode_jingle_s5b_transport_$candidates'([Candidates | _els], __TopXMLNS, _acc) -> 'encode_jingle_s5b_transport_$candidates'(_els, __TopXMLNS, [encode_jingle_s5b_candidate(Candidates, __TopXMLNS) | _acc]). 'encode_jingle_s5b_transport_$activated'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_s5b_transport_$activated'(Activated, __TopXMLNS, _acc) -> [encode_jingle_s5b_activated(Activated, __TopXMLNS) | _acc]. 'encode_jingle_s5b_transport_$candidate-used'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_s5b_transport_$candidate-used'(Candidate_used, __TopXMLNS, _acc) -> [encode_jingle_s5b_candidate_used(Candidate_used, __TopXMLNS) | _acc]. decode_jingle_s5b_transport_attr_sid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"sid">>, <<"transport">>, __TopXMLNS}}); decode_jingle_s5b_transport_attr_sid(__TopXMLNS, _val) -> _val. encode_jingle_s5b_transport_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. decode_jingle_s5b_transport_attr_dstaddr(__TopXMLNS, undefined) -> <<>>; decode_jingle_s5b_transport_attr_dstaddr(__TopXMLNS, _val) -> _val. encode_jingle_s5b_transport_attr_dstaddr(<<>>, _acc) -> _acc; encode_jingle_s5b_transport_attr_dstaddr(_val, _acc) -> [{<<"dstaddr">>, _val} | _acc]. decode_jingle_s5b_transport_attr_mode(__TopXMLNS, undefined) -> tcp; decode_jingle_s5b_transport_attr_mode(__TopXMLNS, _val) -> case catch dec_enum(_val, [tcp, udp]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"mode">>, <<"transport">>, __TopXMLNS}}); _res -> _res end. encode_jingle_s5b_transport_attr_mode(tcp, _acc) -> _acc; encode_jingle_s5b_transport_attr_mode(_val, _acc) -> [{<<"mode">>, enc_enum(_val)} | _acc]. decode_jingle_s5b_proxy_error(__TopXMLNS, __Opts, {xmlel, <<"proxy-error">>, _attrs, _els}) -> 'proxy-error'. encode_jingle_s5b_proxy_error('proxy-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:transports:s5b:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"proxy-error">>, _attrs, _els}. decode_jingle_s5b_candidate_error(__TopXMLNS, __Opts, {xmlel, <<"candidate-error">>, _attrs, _els}) -> 'candidate-error'. encode_jingle_s5b_candidate_error('candidate-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:transports:s5b:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"candidate-error">>, _attrs, _els}. decode_jingle_s5b_activated(__TopXMLNS, __Opts, {xmlel, <<"activated">>, _attrs, _els}) -> Cid = decode_jingle_s5b_activated_attrs(__TopXMLNS, _attrs, undefined), Cid. decode_jingle_s5b_activated_attrs(__TopXMLNS, [{<<"cid">>, _val} | _attrs], _Cid) -> decode_jingle_s5b_activated_attrs(__TopXMLNS, _attrs, _val); decode_jingle_s5b_activated_attrs(__TopXMLNS, [_ | _attrs], Cid) -> decode_jingle_s5b_activated_attrs(__TopXMLNS, _attrs, Cid); decode_jingle_s5b_activated_attrs(__TopXMLNS, [], Cid) -> decode_jingle_s5b_activated_attr_cid(__TopXMLNS, Cid). encode_jingle_s5b_activated(Cid, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:transports:s5b:1">>, [], __TopXMLNS), _els = [], _attrs = encode_jingle_s5b_activated_attr_cid(Cid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"activated">>, _attrs, _els}. decode_jingle_s5b_activated_attr_cid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"cid">>, <<"activated">>, __TopXMLNS}}); decode_jingle_s5b_activated_attr_cid(__TopXMLNS, _val) -> _val. encode_jingle_s5b_activated_attr_cid(_val, _acc) -> [{<<"cid">>, _val} | _acc]. decode_jingle_s5b_candidate(__TopXMLNS, __Opts, {xmlel, <<"candidate">>, _attrs, _els}) -> {Cid, Host, Jid, Port, Priority, Type} = decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined, undefined), {jingle_s5b_candidate, Cid, Host, Port, Jid, Type, Priority}. decode_jingle_s5b_candidate_attrs(__TopXMLNS, [{<<"cid">>, _val} | _attrs], _Cid, Host, Jid, Port, Priority, Type) -> decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, _val, Host, Jid, Port, Priority, Type); decode_jingle_s5b_candidate_attrs(__TopXMLNS, [{<<"host">>, _val} | _attrs], Cid, _Host, Jid, Port, Priority, Type) -> decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, Cid, _val, Jid, Port, Priority, Type); decode_jingle_s5b_candidate_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Cid, Host, _Jid, Port, Priority, Type) -> decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, Cid, Host, _val, Port, Priority, Type); decode_jingle_s5b_candidate_attrs(__TopXMLNS, [{<<"port">>, _val} | _attrs], Cid, Host, Jid, _Port, Priority, Type) -> decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, Cid, Host, Jid, _val, Priority, Type); decode_jingle_s5b_candidate_attrs(__TopXMLNS, [{<<"priority">>, _val} | _attrs], Cid, Host, Jid, Port, _Priority, Type) -> decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, Cid, Host, Jid, Port, _val, Type); decode_jingle_s5b_candidate_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Cid, Host, Jid, Port, Priority, _Type) -> decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, Cid, Host, Jid, Port, Priority, _val); decode_jingle_s5b_candidate_attrs(__TopXMLNS, [_ | _attrs], Cid, Host, Jid, Port, Priority, Type) -> decode_jingle_s5b_candidate_attrs(__TopXMLNS, _attrs, Cid, Host, Jid, Port, Priority, Type); decode_jingle_s5b_candidate_attrs(__TopXMLNS, [], Cid, Host, Jid, Port, Priority, Type) -> {decode_jingle_s5b_candidate_attr_cid(__TopXMLNS, Cid), decode_jingle_s5b_candidate_attr_host(__TopXMLNS, Host), decode_jingle_s5b_candidate_attr_jid(__TopXMLNS, Jid), decode_jingle_s5b_candidate_attr_port(__TopXMLNS, Port), decode_jingle_s5b_candidate_attr_priority(__TopXMLNS, Priority), decode_jingle_s5b_candidate_attr_type(__TopXMLNS, Type)}. encode_jingle_s5b_candidate({jingle_s5b_candidate, Cid, Host, Port, Jid, Type, Priority}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:transports:s5b:1">>, [], __TopXMLNS), _els = [], _attrs = encode_jingle_s5b_candidate_attr_type(Type, encode_jingle_s5b_candidate_attr_priority(Priority, encode_jingle_s5b_candidate_attr_port(Port, encode_jingle_s5b_candidate_attr_jid(Jid, encode_jingle_s5b_candidate_attr_host(Host, encode_jingle_s5b_candidate_attr_cid(Cid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))))), {xmlel, <<"candidate">>, _attrs, _els}. decode_jingle_s5b_candidate_attr_cid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"cid">>, <<"candidate">>, __TopXMLNS}}); decode_jingle_s5b_candidate_attr_cid(__TopXMLNS, _val) -> _val. encode_jingle_s5b_candidate_attr_cid(_val, _acc) -> [{<<"cid">>, _val} | _acc]. decode_jingle_s5b_candidate_attr_host(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"host">>, <<"candidate">>, __TopXMLNS}}); decode_jingle_s5b_candidate_attr_host(__TopXMLNS, _val) -> case catch dec_ip(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"host">>, <<"candidate">>, __TopXMLNS}}); _res -> _res end. encode_jingle_s5b_candidate_attr_host(_val, _acc) -> [{<<"host">>, enc_ip(_val)} | _acc]. decode_jingle_s5b_candidate_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"candidate">>, __TopXMLNS}}); decode_jingle_s5b_candidate_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"candidate">>, __TopXMLNS}}); _res -> _res end. encode_jingle_s5b_candidate_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_jingle_s5b_candidate_attr_port(__TopXMLNS, undefined) -> undefined; decode_jingle_s5b_candidate_attr_port(__TopXMLNS, _val) -> case catch dec_int(_val, 0, 65535) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"port">>, <<"candidate">>, __TopXMLNS}}); _res -> _res end. encode_jingle_s5b_candidate_attr_port(undefined, _acc) -> _acc; encode_jingle_s5b_candidate_attr_port(_val, _acc) -> [{<<"port">>, enc_int(_val)} | _acc]. decode_jingle_s5b_candidate_attr_priority(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"priority">>, <<"candidate">>, __TopXMLNS}}); decode_jingle_s5b_candidate_attr_priority(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"priority">>, <<"candidate">>, __TopXMLNS}}); _res -> _res end. encode_jingle_s5b_candidate_attr_priority(_val, _acc) -> [{<<"priority">>, enc_int(_val)} | _acc]. decode_jingle_s5b_candidate_attr_type(__TopXMLNS, undefined) -> direct; decode_jingle_s5b_candidate_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [assisted, direct, proxy, tunnel]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"candidate">>, __TopXMLNS}}); _res -> _res end. encode_jingle_s5b_candidate_attr_type(direct, _acc) -> _acc; encode_jingle_s5b_candidate_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_jingle_s5b_candidate_used(__TopXMLNS, __Opts, {xmlel, <<"candidate-used">>, _attrs, _els}) -> Cid = decode_jingle_s5b_candidate_used_attrs(__TopXMLNS, _attrs, undefined), Cid. decode_jingle_s5b_candidate_used_attrs(__TopXMLNS, [{<<"cid">>, _val} | _attrs], _Cid) -> decode_jingle_s5b_candidate_used_attrs(__TopXMLNS, _attrs, _val); decode_jingle_s5b_candidate_used_attrs(__TopXMLNS, [_ | _attrs], Cid) -> decode_jingle_s5b_candidate_used_attrs(__TopXMLNS, _attrs, Cid); decode_jingle_s5b_candidate_used_attrs(__TopXMLNS, [], Cid) -> decode_jingle_s5b_candidate_used_attr_cid(__TopXMLNS, Cid). encode_jingle_s5b_candidate_used(Cid, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:transports:s5b:1">>, [], __TopXMLNS), _els = [], _attrs = encode_jingle_s5b_candidate_used_attr_cid(Cid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"candidate-used">>, _attrs, _els}. decode_jingle_s5b_candidate_used_attr_cid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"cid">>, <<"candidate-used">>, __TopXMLNS}}); decode_jingle_s5b_candidate_used_attr_cid(__TopXMLNS, _val) -> _val. encode_jingle_s5b_candidate_used_attr_cid(_val, _acc) -> [{<<"cid">>, _val} | _acc]. xmpp-1.4.4/src/xmpp_socket.erl0000644000232200023220000003255113610066730016711 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_socket). -author('alexey@process-one.net'). -dialyzer({no_match, [send/2, parse/2]}). %% API -export([new/3, connect/3, connect/4, connect/5, starttls/2, compress/1, compress/2, reset_stream/1, send_element/2, send_header/2, send_trailer/1, send/2, send_xml/2, recv/2, activate/1, change_shaper/2, monitor/1, get_sockmod/1, get_transport/1, get_peer_certificate/2, get_verify_result/1, close/1, pp/1, sockname/1, peername/1, send_ws_ping/1]). -include("xmpp.hrl"). -include_lib("public_key/include/public_key.hrl"). -type sockmod() :: gen_tcp | fast_tls | ezlib | ext_mod(). -type socket() :: inet:socket() | fast_tls:tls_socket() | ezlib:zlib_socket() | ext_socket(). -type ext_mod() :: module(). -type ext_socket() :: any(). -type endpoint() :: {inet:ip_address(), inet:port_number()}. -type stream_element() :: {xmlstreamelement, fxml:xmlel()} | {xmlstreamstart, binary(), [{binary(), binary()}]} | {xmlstreamend, binary()} | {xmlstreamraw, iodata()}. -type cert() :: #'Certificate'{} | #'OTPCertificate'{}. -record(socket_state, {sockmod :: sockmod(), socket :: socket(), max_stanza_size :: timeout(), xml_stream :: undefined | fxml_stream:xml_stream_state(), shaper = none :: none | p1_shaper:state(), sock_peer_name = none :: none | {endpoint(), endpoint()}}). -type socket_state() :: #socket_state{}. -export_type([socket/0, socket_state/0, sockmod/0]). -callback send_xml(ext_socket(), stream_element()) -> ok | {error, inet:posix()}. -callback get_owner(ext_socket()) -> pid(). -callback get_transport(ext_socket()) -> atom(). -callback change_shaper(ext_socket(), none | p1_shaper:state()) -> ok. -callback controlling_process(ext_socket(), pid()) -> ok | {error, inet:posix()}. -callback close(ext_socket()) -> ok | {error, inet:posix()}. -callback sockname(ext_socket()) -> {ok, endpoint()} | {error, inet:posix()}. -callback peername(ext_socket()) -> {ok, endpoint()} | {error, inet:posix()}. -callback setopts(ext_socket(), [{active, once}]) -> ok | {error, inet:posix()}. -callback get_peer_certificate(ext_socket(), plain|otp|der) -> {ok, cert() | binary()} | error. -optional_callbacks([get_peer_certificate/2]). -define(dbg(Fmt, Args), case xmpp_config:debug(global) of {ok, true} -> error_logger:info_msg(Fmt, Args); _ -> false end). %%==================================================================== %% API %%==================================================================== -spec new(sockmod(), socket(), [proplists:property()]) -> socket_state(). new(SockMod, Socket, Opts) -> MaxStanzaSize = proplists:get_value(max_stanza_size, Opts, infinity), SockPeer = proplists:get_value(sock_peer_name, Opts, none), XMLStream = case get_owner(SockMod, Socket) of Pid when Pid == self() -> fxml_stream:new(self(), MaxStanzaSize); _ -> undefined end, #socket_state{sockmod = SockMod, socket = Socket, xml_stream = XMLStream, max_stanza_size = MaxStanzaSize, sock_peer_name = SockPeer}. connect(Addr, Port, Opts) -> connect(Addr, Port, Opts, infinity, self()). connect(Addr, Port, Opts, Timeout) -> connect(Addr, Port, Opts, Timeout, self()). connect(Addr, Port, Opts, Timeout, Owner) -> case gen_tcp:connect(Addr, Port, Opts, Timeout) of {ok, Socket} -> SocketData = new(gen_tcp, Socket, []), case controlling_process(SocketData, Owner) of ok -> activate_after(Socket, Owner, 0), {ok, SocketData}; {error, _Reason} = Error -> gen_tcp:close(Socket), Error end; {error, _Reason} = Error -> Error end. -spec starttls(socket_state(), [proplists:property()]) -> {ok, socket_state()} | {error, inet:posix() | atom() | binary()}. starttls(#socket_state{sockmod = gen_tcp, socket = Socket} = SocketData, TLSOpts) -> case fast_tls:tcp_to_tls(Socket, TLSOpts) of {ok, TLSSocket} -> SocketData1 = SocketData#socket_state{socket = TLSSocket, sockmod = fast_tls}, SocketData2 = reset_stream(SocketData1), case fast_tls:recv_data(TLSSocket, <<>>) of {ok, TLSData} -> parse(SocketData2, TLSData); {error, _} = Err -> Err end; {error, _} = Err -> Err end; starttls(_, _) -> erlang:error(badarg). compress(SocketData) -> compress(SocketData, undefined). compress(#socket_state{sockmod = SockMod, socket = Socket} = SocketData, Data) when SockMod == gen_tcp orelse SockMod == fast_tls -> {ok, ZlibSocket} = ezlib:enable_zlib(SockMod, Socket), case Data of undefined -> ok; _ -> send(SocketData, Data) end, SocketData1 = SocketData#socket_state{socket = ZlibSocket, sockmod = ezlib}, SocketData2 = reset_stream(SocketData1), case ezlib:recv_data(ZlibSocket, <<"">>) of {ok, ZlibData} -> parse(SocketData2, ZlibData); {error, _} = Err -> Err end; compress(_, _) -> erlang:error(badarg). reset_stream(#socket_state{xml_stream = XMLStream, sockmod = SockMod, socket = Socket, max_stanza_size = MaxStanzaSize} = SocketData) -> if XMLStream /= undefined -> XMLStream1 = try fxml_stream:reset(XMLStream) catch error:_ -> fxml_stream:close(XMLStream), fxml_stream:new(self(), MaxStanzaSize) end, SocketData#socket_state{xml_stream = XMLStream1}; true -> Socket1 = SockMod:reset_stream(Socket), SocketData#socket_state{socket = Socket1} end. -spec send_element(socket_state(), fxml:xmlel()) -> ok | {error, inet:posix()}. send_element(#socket_state{xml_stream = undefined} = SocketData, El) -> send_xml(SocketData, {xmlstreamelement, El}); send_element(SocketData, El) -> send(SocketData, fxml:element_to_binary(El)). -spec send_header(socket_state(), fxml:xmlel()) -> ok | {error, inet:posix()}. send_header(#socket_state{xml_stream = undefined} = SocketData, El) -> send_xml(SocketData, {xmlstreamstart, El#xmlel.name, El#xmlel.attrs}); send_header(SocketData, El) -> send(SocketData, fxml:element_to_header(El)). -spec send_trailer(socket_state()) -> ok | {error, inet:posix()}. send_trailer(#socket_state{xml_stream = undefined} = SocketData) -> send_xml(SocketData, {xmlstreamend, <<"stream:stream">>}); send_trailer(SocketData) -> send(SocketData, <<"">>). -spec send_ws_ping(socket_state()) -> ok | {error, inet:posix()}. send_ws_ping(#socket_state{xml_stream = undefined}) -> % we don't send cdata on xmlsockets ok; send_ws_ping(SocketData) -> send(SocketData, <<"\r\n\r\n">>). -spec send(socket_state(), iodata()) -> ok | {error, closed | inet:posix()}. send(#socket_state{sockmod = SockMod, socket = Socket} = SocketData, Data) -> ?dbg("(~s) Send XML on stream = ~p", [pp(SocketData), Data]), try SockMod:send(Socket, Data) of {error, einval} -> {error, closed}; Result -> Result catch _:badarg -> %% Some modules throw badarg exceptions on closed sockets %% TODO: their code should be improved {error, closed} end. -spec send_xml(socket_state(), stream_element()) -> ok | {error, any()}. send_xml(#socket_state{sockmod = SockMod, socket = Socket} = SocketData, El) -> ?dbg("(~s) Send XML on stream = ~p", [pp(SocketData), stringify_stream_element(El)]), SockMod:send_xml(Socket, El). stringify_stream_element({xmlstreamstart, Name, Attrs}) -> fxml:element_to_header(#xmlel{name = Name, attrs = Attrs}); stringify_stream_element({xmlstreamend, Name}) -> <<"">>; stringify_stream_element({xmlstreamelement, El}) -> fxml:element_to_binary(El); stringify_stream_element({xmlstreamerror, Data}) -> Err = iolist_to_binary(io_lib:format("~p", [Data])), <<"!StreamError: ", Err/binary>>; stringify_stream_element({xmlstreamraw, Data}) -> Data. recv(#socket_state{sockmod = SockMod, socket = Socket} = SocketData, Data) -> case SockMod of fast_tls -> case fast_tls:recv_data(Socket, Data) of {ok, TLSData} -> parse(SocketData, TLSData); {error, _} = Err -> Err end; ezlib -> case ezlib:recv_data(Socket, Data) of {ok, ZlibData} -> parse(SocketData, ZlibData); {error, _} = Err -> Err end; _ -> parse(SocketData, Data) end. -spec change_shaper(socket_state(), none | p1_shaper:state()) -> socket_state(). change_shaper(#socket_state{xml_stream = XMLStream, sockmod = SockMod, socket = Socket} = SocketData, Shaper) -> if XMLStream /= undefined -> SocketData#socket_state{shaper = Shaper}; true -> SockMod:change_shaper(Socket, Shaper), SocketData end. monitor(#socket_state{xml_stream = undefined, sockmod = SockMod, socket = Socket}) -> erlang:monitor(process, SockMod:get_owner(Socket)); monitor(_) -> make_ref(). controlling_process(#socket_state{sockmod = SockMod, socket = Socket}, Pid) -> SockMod:controlling_process(Socket, Pid). get_sockmod(SocketData) -> SocketData#socket_state.sockmod. get_transport(#socket_state{sockmod = SockMod, socket = Socket}) -> case SockMod of gen_tcp -> tcp; fast_tls -> tls; ezlib -> case ezlib:get_sockmod(Socket) of gen_tcp -> tcp_zlib; fast_tls -> tls_zlib end; _ -> SockMod:get_transport(Socket) end. get_owner(SockMod, _) when SockMod == gen_tcp orelse SockMod == fast_tls orelse SockMod == ezlib -> self(); get_owner(SockMod, Socket) -> SockMod:get_owner(Socket). -spec get_peer_certificate(socket_state(), plain|otp) -> {ok, cert()} | error; (socket_state(), der) -> {ok, binary()} | error. get_peer_certificate(#socket_state{sockmod = SockMod, socket = Socket}, Type) -> case erlang:function_exported(SockMod, get_peer_certificate, 2) of true -> SockMod:get_peer_certificate(Socket, Type); false -> error end. get_verify_result(SocketData) -> fast_tls:get_verify_result(SocketData#socket_state.socket). close(#socket_state{sockmod = SockMod, socket = Socket}) -> SockMod:close(Socket). -spec sockname(socket_state()) -> {ok, endpoint()} | {error, inet:posix()}. sockname(#socket_state{sockmod = SockMod, socket = Socket, sock_peer_name = SockPeer}) -> case SockPeer of none -> case SockMod of gen_tcp -> inet:sockname(Socket); _ -> SockMod:sockname(Socket) end; {SN, _} -> {ok, SN} end. -spec peername(socket_state()) -> {ok, endpoint()} | {error, inet:posix()}. peername(#socket_state{sockmod = SockMod, socket = Socket, sock_peer_name = SockPeer}) -> case SockPeer of none -> case SockMod of gen_tcp -> inet:peername(Socket); _ -> SockMod:peername(Socket) end; {_, PN} -> {ok, PN} end. activate(#socket_state{sockmod = SockMod, socket = Socket}) -> case SockMod of gen_tcp -> inet:setopts(Socket, [{active, once}]); _ -> SockMod:setopts(Socket, [{active, once}]) end. activate_after(Socket, Pid, Pause) -> if Pause > 0 -> erlang:send_after(Pause, Pid, {tcp, Socket, <<>>}); true -> Pid ! {tcp, Socket, <<>>} end, ok. pp(#socket_state{sockmod = SockMod, socket = Socket} = State) -> Transport = get_transport(State), Receiver = get_owner(SockMod, Socket), io_lib:format("~s|~w", [Transport, Receiver]). parse(SocketData, Data) when Data == <<>>; Data == [] -> case activate(SocketData) of ok -> {ok, SocketData}; {error, _} = Err -> Err end; parse(SocketData, [El | Els]) when is_record(El, xmlel) -> ?dbg("(~s) Received XML on stream = ~p", [pp(SocketData), fxml:element_to_binary(El)]), self() ! {'$gen_event', {xmlstreamelement, El}}, parse(SocketData, Els); parse(SocketData, [El | Els]) when element(1, El) == xmlstreamstart; element(1, El) == xmlstreamelement; element(1, El) == xmlstreamend; element(1, El) == xmlstreamerror -> ?dbg("(~s) Received XML on stream = ~p", [pp(SocketData), stringify_stream_element(El)]), self() ! {'$gen_event', El}, parse(SocketData, Els); parse(#socket_state{xml_stream = XMLStream, socket = Socket, shaper = ShaperState} = SocketData, Data) when is_binary(Data) -> ?dbg("(~s) Received XML on stream = ~p", [pp(SocketData), Data]), XMLStream1 = fxml_stream:parse(XMLStream, Data), {ShaperState1, Pause} = shaper_update(ShaperState, byte_size(Data)), Ret = if Pause > 0 -> activate_after(Socket, self(), Pause); true -> activate(SocketData) end, case Ret of ok -> {ok, SocketData#socket_state{xml_stream = XMLStream1, shaper = ShaperState1}}; {error, _} = Err -> Err end. shaper_update(none, _) -> {none, 0}; shaper_update(Shaper, Size) -> p1_shaper:update(Shaper, Size). xmpp-1.4.4/src/xep0203.erl0000644000232200023220000000663613610066730015463 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0203). -compile(export_all). do_decode(<<"delay">>, <<"urn:xmpp:delay">>, El, Opts) -> decode_delay(<<"urn:xmpp:delay">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"delay">>, <<"urn:xmpp:delay">>}]. do_encode({delay, _, _, _} = Delay, TopXMLNS) -> encode_delay(Delay, TopXMLNS). do_get_name({delay, _, _, _}) -> <<"delay">>. do_get_ns({delay, _, _, _}) -> <<"urn:xmpp:delay">>. pp(delay, 3) -> [stamp, from, desc]; pp(_, _) -> no. records() -> [{delay, 3}]. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_delay(__TopXMLNS, __Opts, {xmlel, <<"delay">>, _attrs, _els}) -> Desc = decode_delay_els(__TopXMLNS, __Opts, _els, <<>>), {Stamp, From} = decode_delay_attrs(__TopXMLNS, _attrs, undefined, undefined), {delay, Stamp, From, Desc}. decode_delay_els(__TopXMLNS, __Opts, [], Desc) -> decode_delay_cdata(__TopXMLNS, Desc); decode_delay_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Desc) -> decode_delay_els(__TopXMLNS, __Opts, _els, <>); decode_delay_els(__TopXMLNS, __Opts, [_ | _els], Desc) -> decode_delay_els(__TopXMLNS, __Opts, _els, Desc). decode_delay_attrs(__TopXMLNS, [{<<"stamp">>, _val} | _attrs], _Stamp, From) -> decode_delay_attrs(__TopXMLNS, _attrs, _val, From); decode_delay_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], Stamp, _From) -> decode_delay_attrs(__TopXMLNS, _attrs, Stamp, _val); decode_delay_attrs(__TopXMLNS, [_ | _attrs], Stamp, From) -> decode_delay_attrs(__TopXMLNS, _attrs, Stamp, From); decode_delay_attrs(__TopXMLNS, [], Stamp, From) -> {decode_delay_attr_stamp(__TopXMLNS, Stamp), decode_delay_attr_from(__TopXMLNS, From)}. encode_delay({delay, Stamp, From, Desc}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:delay">>, [], __TopXMLNS), _els = encode_delay_cdata(Desc, []), _attrs = encode_delay_attr_from(From, encode_delay_attr_stamp(Stamp, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"delay">>, _attrs, _els}. decode_delay_attr_stamp(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"stamp">>, <<"delay">>, __TopXMLNS}}); decode_delay_attr_stamp(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"stamp">>, <<"delay">>, __TopXMLNS}}); _res -> _res end. encode_delay_attr_stamp(_val, _acc) -> [{<<"stamp">>, enc_utc(_val)} | _acc]. decode_delay_attr_from(__TopXMLNS, undefined) -> undefined; decode_delay_attr_from(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"delay">>, __TopXMLNS}}); _res -> _res end. encode_delay_attr_from(undefined, _acc) -> _acc; encode_delay_attr_from(_val, _acc) -> [{<<"from">>, jid:encode(_val)} | _acc]. decode_delay_cdata(__TopXMLNS, <<>>) -> <<>>; decode_delay_cdata(__TopXMLNS, _val) -> _val. encode_delay_cdata(<<>>, _acc) -> _acc; encode_delay_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xmpp_sup.erl0000644000232200023220000000322613610066730016225 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% %%% @end %%% Created : 3 Mar 2018 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_sup). -behaviour(supervisor). %% API -export([start_link/0]). %% Supervisor callbacks -export([init/1]). %%%=================================================================== %%% API functions %%%=================================================================== start_link() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []). %%%=================================================================== %%% Supervisor callbacks %%%=================================================================== init([]) -> {ok, {{one_for_one, 10, 1}, []}}. %%%=================================================================== %%% Internal functions %%%=================================================================== xmpp-1.4.4/src/xep0279.erl0000644000232200023220000001531113610066730015466 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0279). -compile(export_all). do_decode(<<"address">>, <<"urn:xmpp:sic:0">>, El, Opts) -> decode_sic(<<"urn:xmpp:sic:0">>, Opts, El); do_decode(<<"address">>, <<"urn:xmpp:sic:1">>, El, Opts) -> decode_sic(<<"urn:xmpp:sic:1">>, Opts, El); do_decode(<<"port">>, <<"urn:xmpp:sic:1">>, El, Opts) -> decode_sic_port(<<"urn:xmpp:sic:1">>, Opts, El); do_decode(<<"ip">>, <<"urn:xmpp:sic:0">>, El, Opts) -> decode_sic_ip(<<"urn:xmpp:sic:0">>, Opts, El); do_decode(<<"ip">>, <<"urn:xmpp:sic:1">>, El, Opts) -> decode_sic_ip(<<"urn:xmpp:sic:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"address">>, <<"urn:xmpp:sic:0">>}, {<<"address">>, <<"urn:xmpp:sic:1">>}, {<<"port">>, <<"urn:xmpp:sic:1">>}, {<<"ip">>, <<"urn:xmpp:sic:0">>}, {<<"ip">>, <<"urn:xmpp:sic:1">>}]. do_encode({sic, _, _, _} = Address, TopXMLNS) -> encode_sic(Address, TopXMLNS). do_get_name({sic, _, _, _}) -> <<"address">>. do_get_ns({sic, _, _, Xmlns}) -> Xmlns. pp(sic, 3) -> [ip, port, xmlns]; pp(_, _) -> no. records() -> [{sic, 3}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. dec_ip(S) -> {ok, Addr} = inet_parse:address(binary_to_list(S)), Addr. enc_int(Int) -> erlang:integer_to_binary(Int). enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). decode_sic(__TopXMLNS, __Opts, {xmlel, <<"address">>, _attrs, _els}) -> {Ip, Port} = decode_sic_els(__TopXMLNS, __Opts, _els, undefined, undefined), Xmlns = decode_sic_attrs(__TopXMLNS, _attrs, undefined), {sic, Ip, Port, Xmlns}. decode_sic_els(__TopXMLNS, __Opts, [], Ip, Port) -> {Ip, Port}; decode_sic_els(__TopXMLNS, __Opts, [{xmlel, <<"ip">>, _attrs, _} = _el | _els], Ip, Port) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:sic:0">> -> decode_sic_els(__TopXMLNS, __Opts, _els, decode_sic_ip(<<"urn:xmpp:sic:0">>, __Opts, _el), Port); <<"urn:xmpp:sic:1">> -> decode_sic_els(__TopXMLNS, __Opts, _els, decode_sic_ip(<<"urn:xmpp:sic:1">>, __Opts, _el), Port); _ -> decode_sic_els(__TopXMLNS, __Opts, _els, Ip, Port) end; decode_sic_els(__TopXMLNS, __Opts, [{xmlel, <<"port">>, _attrs, _} = _el | _els], Ip, Port) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:sic:1">> -> decode_sic_els(__TopXMLNS, __Opts, _els, Ip, decode_sic_port(<<"urn:xmpp:sic:1">>, __Opts, _el)); _ -> decode_sic_els(__TopXMLNS, __Opts, _els, Ip, Port) end; decode_sic_els(__TopXMLNS, __Opts, [_ | _els], Ip, Port) -> decode_sic_els(__TopXMLNS, __Opts, _els, Ip, Port). decode_sic_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns) -> decode_sic_attrs(__TopXMLNS, _attrs, _val); decode_sic_attrs(__TopXMLNS, [_ | _attrs], Xmlns) -> decode_sic_attrs(__TopXMLNS, _attrs, Xmlns); decode_sic_attrs(__TopXMLNS, [], Xmlns) -> decode_sic_attr_xmlns(__TopXMLNS, Xmlns). encode_sic({sic, Ip, Port, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:sic:0">>, <<"urn:xmpp:sic:1">>], __TopXMLNS), _els = lists:reverse('encode_sic_$ip'(Ip, __NewTopXMLNS, 'encode_sic_$port'(Port, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"address">>, _attrs, _els}. 'encode_sic_$ip'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_sic_$ip'(Ip, __TopXMLNS, _acc) -> [encode_sic_ip(Ip, __TopXMLNS) | _acc]. 'encode_sic_$port'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_sic_$port'(Port, __TopXMLNS, _acc) -> [encode_sic_port(Port, __TopXMLNS) | _acc]. decode_sic_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_sic_attr_xmlns(__TopXMLNS, _val) -> _val. decode_sic_port(__TopXMLNS, __Opts, {xmlel, <<"port">>, _attrs, _els}) -> Cdata = decode_sic_port_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_sic_port_els(__TopXMLNS, __Opts, [], Cdata) -> decode_sic_port_cdata(__TopXMLNS, Cdata); decode_sic_port_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_sic_port_els(__TopXMLNS, __Opts, _els, <>); decode_sic_port_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_sic_port_els(__TopXMLNS, __Opts, _els, Cdata). encode_sic_port(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:sic:1">>, [], __TopXMLNS), _els = encode_sic_port_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"port">>, _attrs, _els}. decode_sic_port_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"port">>, __TopXMLNS}}); decode_sic_port_cdata(__TopXMLNS, _val) -> case catch dec_int(_val, 0, 65535) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"port">>, __TopXMLNS}}); _res -> _res end. encode_sic_port_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_sic_ip(__TopXMLNS, __Opts, {xmlel, <<"ip">>, _attrs, _els}) -> Cdata = decode_sic_ip_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_sic_ip_els(__TopXMLNS, __Opts, [], Cdata) -> decode_sic_ip_cdata(__TopXMLNS, Cdata); decode_sic_ip_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_sic_ip_els(__TopXMLNS, __Opts, _els, <>); decode_sic_ip_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_sic_ip_els(__TopXMLNS, __Opts, _els, Cdata). encode_sic_ip(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:sic:0">>, <<"urn:xmpp:sic:1">>], __TopXMLNS), _els = encode_sic_ip_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ip">>, _attrs, _els}. decode_sic_ip_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"ip">>, __TopXMLNS}}); decode_sic_ip_cdata(__TopXMLNS, _val) -> case catch dec_ip(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"ip">>, __TopXMLNS}}); _res -> _res end. encode_sic_ip_cdata(_val, _acc) -> [{xmlcdata, enc_ip(_val)} | _acc]. xmpp-1.4.4/src/xep0055.erl0000644000232200023220000004644713610066730015474 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0055). -compile(export_all). do_decode(<<"query">>, <<"jabber:iq:search">>, El, Opts) -> decode_search(<<"jabber:iq:search">>, Opts, El); do_decode(<<"item">>, <<"jabber:iq:search">>, El, Opts) -> decode_search_item(<<"jabber:iq:search">>, Opts, El); do_decode(<<"email">>, <<"jabber:iq:search">>, El, Opts) -> decode_search_email(<<"jabber:iq:search">>, Opts, El); do_decode(<<"nick">>, <<"jabber:iq:search">>, El, Opts) -> decode_search_nick(<<"jabber:iq:search">>, Opts, El); do_decode(<<"last">>, <<"jabber:iq:search">>, El, Opts) -> decode_search_last(<<"jabber:iq:search">>, Opts, El); do_decode(<<"first">>, <<"jabber:iq:search">>, El, Opts) -> decode_search_first(<<"jabber:iq:search">>, Opts, El); do_decode(<<"instructions">>, <<"jabber:iq:search">>, El, Opts) -> decode_search_instructions(<<"jabber:iq:search">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"jabber:iq:search">>}, {<<"item">>, <<"jabber:iq:search">>}, {<<"email">>, <<"jabber:iq:search">>}, {<<"nick">>, <<"jabber:iq:search">>}, {<<"last">>, <<"jabber:iq:search">>}, {<<"first">>, <<"jabber:iq:search">>}, {<<"instructions">>, <<"jabber:iq:search">>}]. do_encode({search_item, _, _, _, _, _} = Item, TopXMLNS) -> encode_search_item(Item, TopXMLNS); do_encode({search, _, _, _, _, _, _, _} = Query, TopXMLNS) -> encode_search(Query, TopXMLNS). do_get_name({search, _, _, _, _, _, _, _}) -> <<"query">>; do_get_name({search_item, _, _, _, _, _}) -> <<"item">>. do_get_ns({search, _, _, _, _, _, _, _}) -> <<"jabber:iq:search">>; do_get_ns({search_item, _, _, _, _, _}) -> <<"jabber:iq:search">>. pp(search_item, 5) -> [jid, first, last, nick, email]; pp(search, 7) -> [instructions, first, last, nick, email, items, xdata]; pp(_, _) -> no. records() -> [{search_item, 5}, {search, 7}]. decode_search(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Xdata, Items, Instructions, Last, First, Nick, Email} = decode_search_els(__TopXMLNS, __Opts, _els, undefined, [], undefined, undefined, undefined, undefined, undefined), {search, Instructions, First, Last, Nick, Email, Items, Xdata}. decode_search_els(__TopXMLNS, __Opts, [], Xdata, Items, Instructions, Last, First, Nick, Email) -> {Xdata, lists:reverse(Items), Instructions, Last, First, Nick, Email}; decode_search_els(__TopXMLNS, __Opts, [{xmlel, <<"instructions">>, _attrs, _} = _el | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, decode_search_instructions(<<"jabber:iq:search">>, __Opts, _el), Last, First, Nick, Email); _ -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email) end; decode_search_els(__TopXMLNS, __Opts, [{xmlel, <<"first">>, _attrs, _} = _el | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, decode_search_first(<<"jabber:iq:search">>, __Opts, _el), Nick, Email); _ -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email) end; decode_search_els(__TopXMLNS, __Opts, [{xmlel, <<"last">>, _attrs, _} = _el | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, decode_search_last(<<"jabber:iq:search">>, __Opts, _el), First, Nick, Email); _ -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email) end; decode_search_els(__TopXMLNS, __Opts, [{xmlel, <<"nick">>, _attrs, _} = _el | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, decode_search_nick(<<"jabber:iq:search">>, __Opts, _el), Email); _ -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email) end; decode_search_els(__TopXMLNS, __Opts, [{xmlel, <<"email">>, _attrs, _} = _el | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, decode_search_email(<<"jabber:iq:search">>, __Opts, _el)); _ -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email) end; decode_search_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, [decode_search_item(<<"jabber:iq:search">>, __Opts, _el) | Items], Instructions, Last, First, Nick, Email); _ -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email) end; decode_search_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_search_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el), Items, Instructions, Last, First, Nick, Email); _ -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email) end; decode_search_els(__TopXMLNS, __Opts, [_ | _els], Xdata, Items, Instructions, Last, First, Nick, Email) -> decode_search_els(__TopXMLNS, __Opts, _els, Xdata, Items, Instructions, Last, First, Nick, Email). encode_search({search, Instructions, First, Last, Nick, Email, Items, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:search">>, [], __TopXMLNS), _els = lists:reverse('encode_search_$xdata'(Xdata, __NewTopXMLNS, 'encode_search_$items'(Items, __NewTopXMLNS, 'encode_search_$instructions'(Instructions, __NewTopXMLNS, 'encode_search_$last'(Last, __NewTopXMLNS, 'encode_search_$first'(First, __NewTopXMLNS, 'encode_search_$nick'(Nick, __NewTopXMLNS, 'encode_search_$email'(Email, __NewTopXMLNS, [])))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. 'encode_search_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. 'encode_search_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_search_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_search_$items'(_els, __TopXMLNS, [encode_search_item(Items, __TopXMLNS) | _acc]). 'encode_search_$instructions'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_$instructions'(Instructions, __TopXMLNS, _acc) -> [encode_search_instructions(Instructions, __TopXMLNS) | _acc]. 'encode_search_$last'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_$last'(Last, __TopXMLNS, _acc) -> [encode_search_last(Last, __TopXMLNS) | _acc]. 'encode_search_$first'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_$first'(First, __TopXMLNS, _acc) -> [encode_search_first(First, __TopXMLNS) | _acc]. 'encode_search_$nick'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_$nick'(Nick, __TopXMLNS, _acc) -> [encode_search_nick(Nick, __TopXMLNS) | _acc]. 'encode_search_$email'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_$email'(Email, __TopXMLNS, _acc) -> [encode_search_email(Email, __TopXMLNS) | _acc]. decode_search_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> {Last, First, Nick, Email} = decode_search_item_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined), Jid = decode_search_item_attrs(__TopXMLNS, _attrs, undefined), {search_item, Jid, First, Last, Nick, Email}. decode_search_item_els(__TopXMLNS, __Opts, [], Last, First, Nick, Email) -> {Last, First, Nick, Email}; decode_search_item_els(__TopXMLNS, __Opts, [{xmlel, <<"first">>, _attrs, _} = _el | _els], Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, decode_search_first(<<"jabber:iq:search">>, __Opts, _el), Nick, Email); _ -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, First, Nick, Email) end; decode_search_item_els(__TopXMLNS, __Opts, [{xmlel, <<"last">>, _attrs, _} = _el | _els], Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_item_els(__TopXMLNS, __Opts, _els, decode_search_last(<<"jabber:iq:search">>, __Opts, _el), First, Nick, Email); _ -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, First, Nick, Email) end; decode_search_item_els(__TopXMLNS, __Opts, [{xmlel, <<"nick">>, _attrs, _} = _el | _els], Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, First, decode_search_nick(<<"jabber:iq:search">>, __Opts, _el), Email); _ -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, First, Nick, Email) end; decode_search_item_els(__TopXMLNS, __Opts, [{xmlel, <<"email">>, _attrs, _} = _el | _els], Last, First, Nick, Email) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:search">> -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, First, Nick, decode_search_email(<<"jabber:iq:search">>, __Opts, _el)); _ -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, First, Nick, Email) end; decode_search_item_els(__TopXMLNS, __Opts, [_ | _els], Last, First, Nick, Email) -> decode_search_item_els(__TopXMLNS, __Opts, _els, Last, First, Nick, Email). decode_search_item_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid) -> decode_search_item_attrs(__TopXMLNS, _attrs, _val); decode_search_item_attrs(__TopXMLNS, [_ | _attrs], Jid) -> decode_search_item_attrs(__TopXMLNS, _attrs, Jid); decode_search_item_attrs(__TopXMLNS, [], Jid) -> decode_search_item_attr_jid(__TopXMLNS, Jid). encode_search_item({search_item, Jid, First, Last, Nick, Email}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:search">>, [], __TopXMLNS), _els = lists:reverse('encode_search_item_$last'(Last, __NewTopXMLNS, 'encode_search_item_$first'(First, __NewTopXMLNS, 'encode_search_item_$nick'(Nick, __NewTopXMLNS, 'encode_search_item_$email'(Email, __NewTopXMLNS, []))))), _attrs = encode_search_item_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"item">>, _attrs, _els}. 'encode_search_item_$last'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_item_$last'(Last, __TopXMLNS, _acc) -> [encode_search_last(Last, __TopXMLNS) | _acc]. 'encode_search_item_$first'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_item_$first'(First, __TopXMLNS, _acc) -> [encode_search_first(First, __TopXMLNS) | _acc]. 'encode_search_item_$nick'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_item_$nick'(Nick, __TopXMLNS, _acc) -> [encode_search_nick(Nick, __TopXMLNS) | _acc]. 'encode_search_item_$email'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_search_item_$email'(Email, __TopXMLNS, _acc) -> [encode_search_email(Email, __TopXMLNS) | _acc]. decode_search_item_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"item">>, __TopXMLNS}}); decode_search_item_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_search_item_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_search_email(__TopXMLNS, __Opts, {xmlel, <<"email">>, _attrs, _els}) -> Cdata = decode_search_email_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_search_email_els(__TopXMLNS, __Opts, [], Cdata) -> decode_search_email_cdata(__TopXMLNS, Cdata); decode_search_email_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_search_email_els(__TopXMLNS, __Opts, _els, <>); decode_search_email_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_search_email_els(__TopXMLNS, __Opts, _els, Cdata). encode_search_email(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:search">>, [], __TopXMLNS), _els = encode_search_email_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"email">>, _attrs, _els}. decode_search_email_cdata(__TopXMLNS, <<>>) -> <<>>; decode_search_email_cdata(__TopXMLNS, _val) -> _val. encode_search_email_cdata(<<>>, _acc) -> _acc; encode_search_email_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_search_nick(__TopXMLNS, __Opts, {xmlel, <<"nick">>, _attrs, _els}) -> Cdata = decode_search_nick_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_search_nick_els(__TopXMLNS, __Opts, [], Cdata) -> decode_search_nick_cdata(__TopXMLNS, Cdata); decode_search_nick_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_search_nick_els(__TopXMLNS, __Opts, _els, <>); decode_search_nick_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_search_nick_els(__TopXMLNS, __Opts, _els, Cdata). encode_search_nick(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:search">>, [], __TopXMLNS), _els = encode_search_nick_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"nick">>, _attrs, _els}. decode_search_nick_cdata(__TopXMLNS, <<>>) -> <<>>; decode_search_nick_cdata(__TopXMLNS, _val) -> _val. encode_search_nick_cdata(<<>>, _acc) -> _acc; encode_search_nick_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_search_last(__TopXMLNS, __Opts, {xmlel, <<"last">>, _attrs, _els}) -> Cdata = decode_search_last_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_search_last_els(__TopXMLNS, __Opts, [], Cdata) -> decode_search_last_cdata(__TopXMLNS, Cdata); decode_search_last_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_search_last_els(__TopXMLNS, __Opts, _els, <>); decode_search_last_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_search_last_els(__TopXMLNS, __Opts, _els, Cdata). encode_search_last(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:search">>, [], __TopXMLNS), _els = encode_search_last_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"last">>, _attrs, _els}. decode_search_last_cdata(__TopXMLNS, <<>>) -> <<>>; decode_search_last_cdata(__TopXMLNS, _val) -> _val. encode_search_last_cdata(<<>>, _acc) -> _acc; encode_search_last_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_search_first(__TopXMLNS, __Opts, {xmlel, <<"first">>, _attrs, _els}) -> Cdata = decode_search_first_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_search_first_els(__TopXMLNS, __Opts, [], Cdata) -> decode_search_first_cdata(__TopXMLNS, Cdata); decode_search_first_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_search_first_els(__TopXMLNS, __Opts, _els, <>); decode_search_first_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_search_first_els(__TopXMLNS, __Opts, _els, Cdata). encode_search_first(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:search">>, [], __TopXMLNS), _els = encode_search_first_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"first">>, _attrs, _els}. decode_search_first_cdata(__TopXMLNS, <<>>) -> <<>>; decode_search_first_cdata(__TopXMLNS, _val) -> _val. encode_search_first_cdata(<<>>, _acc) -> _acc; encode_search_first_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_search_instructions(__TopXMLNS, __Opts, {xmlel, <<"instructions">>, _attrs, _els}) -> Cdata = decode_search_instructions_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_search_instructions_els(__TopXMLNS, __Opts, [], Cdata) -> decode_search_instructions_cdata(__TopXMLNS, Cdata); decode_search_instructions_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_search_instructions_els(__TopXMLNS, __Opts, _els, <>); decode_search_instructions_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_search_instructions_els(__TopXMLNS, __Opts, _els, Cdata). encode_search_instructions(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:search">>, [], __TopXMLNS), _els = encode_search_instructions_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"instructions">>, _attrs, _els}. decode_search_instructions_cdata(__TopXMLNS, <<>>) -> <<>>; decode_search_instructions_cdata(__TopXMLNS, _val) -> _val. encode_search_instructions_cdata(<<>>, _acc) -> _acc; encode_search_instructions_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0054.erl0000644000232200023220000054071113610066730015464 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0054). -compile(export_all). do_decode(<<"vCard">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_temp(<<"vcard-temp">>, Opts, El); do_decode(<<"CLASS">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_CLASS(<<"vcard-temp">>, Opts, El); do_decode(<<"CATEGORIES">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_CATEGORIES(<<"vcard-temp">>, Opts, El); do_decode(<<"KEY">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_KEY(<<"vcard-temp">>, Opts, El); do_decode(<<"SOUND">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_SOUND(<<"vcard-temp">>, Opts, El); do_decode(<<"ORG">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_ORG(<<"vcard-temp">>, Opts, El); do_decode(<<"PHOTO">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PHOTO(<<"vcard-temp">>, Opts, El); do_decode(<<"LOGO">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_LOGO(<<"vcard-temp">>, Opts, El); do_decode(<<"BINVAL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_BINVAL(<<"vcard-temp">>, Opts, El); do_decode(<<"GEO">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_GEO(<<"vcard-temp">>, Opts, El); do_decode(<<"EMAIL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_EMAIL(<<"vcard-temp">>, Opts, El); do_decode(<<"TEL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_TEL(<<"vcard-temp">>, Opts, El); do_decode(<<"LABEL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_LABEL(<<"vcard-temp">>, Opts, El); do_decode(<<"ADR">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_ADR(<<"vcard-temp">>, Opts, El); do_decode(<<"N">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_N(<<"vcard-temp">>, Opts, El); do_decode(<<"CONFIDENTIAL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_CONFIDENTIAL(<<"vcard-temp">>, Opts, El); do_decode(<<"PRIVATE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PRIVATE(<<"vcard-temp">>, Opts, El); do_decode(<<"PUBLIC">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PUBLIC(<<"vcard-temp">>, Opts, El); do_decode(<<"EXTVAL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_EXTVAL(<<"vcard-temp">>, Opts, El); do_decode(<<"TYPE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_TYPE(<<"vcard-temp">>, Opts, El); do_decode(<<"DESC">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_DESC(<<"vcard-temp">>, Opts, El); do_decode(<<"URL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_URL(<<"vcard-temp">>, Opts, El); do_decode(<<"UID">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_UID(<<"vcard-temp">>, Opts, El); do_decode(<<"SORT-STRING">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_SORT_STRING(<<"vcard-temp">>, Opts, El); do_decode(<<"REV">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_REV(<<"vcard-temp">>, Opts, El); do_decode(<<"PRODID">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PRODID(<<"vcard-temp">>, Opts, El); do_decode(<<"NOTE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_NOTE(<<"vcard-temp">>, Opts, El); do_decode(<<"KEYWORD">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_KEYWORD(<<"vcard-temp">>, Opts, El); do_decode(<<"ROLE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_ROLE(<<"vcard-temp">>, Opts, El); do_decode(<<"TITLE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_TITLE(<<"vcard-temp">>, Opts, El); do_decode(<<"TZ">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_TZ(<<"vcard-temp">>, Opts, El); do_decode(<<"MAILER">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_MAILER(<<"vcard-temp">>, Opts, El); do_decode(<<"JABBERID">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_JABBERID(<<"vcard-temp">>, Opts, El); do_decode(<<"BDAY">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_BDAY(<<"vcard-temp">>, Opts, El); do_decode(<<"NICKNAME">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_NICKNAME(<<"vcard-temp">>, Opts, El); do_decode(<<"FN">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_FN(<<"vcard-temp">>, Opts, El); do_decode(<<"VERSION">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_VERSION(<<"vcard-temp">>, Opts, El); do_decode(<<"CRED">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_CRED(<<"vcard-temp">>, Opts, El); do_decode(<<"PHONETIC">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PHONETIC(<<"vcard-temp">>, Opts, El); do_decode(<<"ORGUNIT">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_ORGUNIT(<<"vcard-temp">>, Opts, El); do_decode(<<"ORGNAME">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_ORGNAME(<<"vcard-temp">>, Opts, El); do_decode(<<"LON">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_LON(<<"vcard-temp">>, Opts, El); do_decode(<<"LAT">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_LAT(<<"vcard-temp">>, Opts, El); do_decode(<<"USERID">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_USERID(<<"vcard-temp">>, Opts, El); do_decode(<<"NUMBER">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_NUMBER(<<"vcard-temp">>, Opts, El); do_decode(<<"LINE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_LINE(<<"vcard-temp">>, Opts, El); do_decode(<<"CTRY">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_CTRY(<<"vcard-temp">>, Opts, El); do_decode(<<"PCODE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PCODE(<<"vcard-temp">>, Opts, El); do_decode(<<"REGION">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_REGION(<<"vcard-temp">>, Opts, El); do_decode(<<"LOCALITY">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_LOCALITY(<<"vcard-temp">>, Opts, El); do_decode(<<"STREET">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_STREET(<<"vcard-temp">>, Opts, El); do_decode(<<"EXTADD">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_EXTADD(<<"vcard-temp">>, Opts, El); do_decode(<<"POBOX">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_POBOX(<<"vcard-temp">>, Opts, El); do_decode(<<"SUFFIX">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_SUFFIX(<<"vcard-temp">>, Opts, El); do_decode(<<"PREFIX">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PREFIX(<<"vcard-temp">>, Opts, El); do_decode(<<"MIDDLE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_MIDDLE(<<"vcard-temp">>, Opts, El); do_decode(<<"GIVEN">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_GIVEN(<<"vcard-temp">>, Opts, El); do_decode(<<"FAMILY">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_FAMILY(<<"vcard-temp">>, Opts, El); do_decode(<<"X400">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_X400(<<"vcard-temp">>, Opts, El); do_decode(<<"INTERNET">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_INTERNET(<<"vcard-temp">>, Opts, El); do_decode(<<"PREF">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PREF(<<"vcard-temp">>, Opts, El); do_decode(<<"INTL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_INTL(<<"vcard-temp">>, Opts, El); do_decode(<<"DOM">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_DOM(<<"vcard-temp">>, Opts, El); do_decode(<<"PARCEL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PARCEL(<<"vcard-temp">>, Opts, El); do_decode(<<"POSTAL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_POSTAL(<<"vcard-temp">>, Opts, El); do_decode(<<"PCS">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PCS(<<"vcard-temp">>, Opts, El); do_decode(<<"ISDN">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_ISDN(<<"vcard-temp">>, Opts, El); do_decode(<<"MODEM">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_MODEM(<<"vcard-temp">>, Opts, El); do_decode(<<"BBS">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_BBS(<<"vcard-temp">>, Opts, El); do_decode(<<"VIDEO">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_VIDEO(<<"vcard-temp">>, Opts, El); do_decode(<<"CELL">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_CELL(<<"vcard-temp">>, Opts, El); do_decode(<<"MSG">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_MSG(<<"vcard-temp">>, Opts, El); do_decode(<<"PAGER">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_PAGER(<<"vcard-temp">>, Opts, El); do_decode(<<"FAX">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_FAX(<<"vcard-temp">>, Opts, El); do_decode(<<"VOICE">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_VOICE(<<"vcard-temp">>, Opts, El); do_decode(<<"WORK">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_WORK(<<"vcard-temp">>, Opts, El); do_decode(<<"HOME">>, <<"vcard-temp">>, El, Opts) -> decode_vcard_HOME(<<"vcard-temp">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"vCard">>, <<"vcard-temp">>}, {<<"CLASS">>, <<"vcard-temp">>}, {<<"CATEGORIES">>, <<"vcard-temp">>}, {<<"KEY">>, <<"vcard-temp">>}, {<<"SOUND">>, <<"vcard-temp">>}, {<<"ORG">>, <<"vcard-temp">>}, {<<"PHOTO">>, <<"vcard-temp">>}, {<<"LOGO">>, <<"vcard-temp">>}, {<<"BINVAL">>, <<"vcard-temp">>}, {<<"GEO">>, <<"vcard-temp">>}, {<<"EMAIL">>, <<"vcard-temp">>}, {<<"TEL">>, <<"vcard-temp">>}, {<<"LABEL">>, <<"vcard-temp">>}, {<<"ADR">>, <<"vcard-temp">>}, {<<"N">>, <<"vcard-temp">>}, {<<"CONFIDENTIAL">>, <<"vcard-temp">>}, {<<"PRIVATE">>, <<"vcard-temp">>}, {<<"PUBLIC">>, <<"vcard-temp">>}, {<<"EXTVAL">>, <<"vcard-temp">>}, {<<"TYPE">>, <<"vcard-temp">>}, {<<"DESC">>, <<"vcard-temp">>}, {<<"URL">>, <<"vcard-temp">>}, {<<"UID">>, <<"vcard-temp">>}, {<<"SORT-STRING">>, <<"vcard-temp">>}, {<<"REV">>, <<"vcard-temp">>}, {<<"PRODID">>, <<"vcard-temp">>}, {<<"NOTE">>, <<"vcard-temp">>}, {<<"KEYWORD">>, <<"vcard-temp">>}, {<<"ROLE">>, <<"vcard-temp">>}, {<<"TITLE">>, <<"vcard-temp">>}, {<<"TZ">>, <<"vcard-temp">>}, {<<"MAILER">>, <<"vcard-temp">>}, {<<"JABBERID">>, <<"vcard-temp">>}, {<<"BDAY">>, <<"vcard-temp">>}, {<<"NICKNAME">>, <<"vcard-temp">>}, {<<"FN">>, <<"vcard-temp">>}, {<<"VERSION">>, <<"vcard-temp">>}, {<<"CRED">>, <<"vcard-temp">>}, {<<"PHONETIC">>, <<"vcard-temp">>}, {<<"ORGUNIT">>, <<"vcard-temp">>}, {<<"ORGNAME">>, <<"vcard-temp">>}, {<<"LON">>, <<"vcard-temp">>}, {<<"LAT">>, <<"vcard-temp">>}, {<<"USERID">>, <<"vcard-temp">>}, {<<"NUMBER">>, <<"vcard-temp">>}, {<<"LINE">>, <<"vcard-temp">>}, {<<"CTRY">>, <<"vcard-temp">>}, {<<"PCODE">>, <<"vcard-temp">>}, {<<"REGION">>, <<"vcard-temp">>}, {<<"LOCALITY">>, <<"vcard-temp">>}, {<<"STREET">>, <<"vcard-temp">>}, {<<"EXTADD">>, <<"vcard-temp">>}, {<<"POBOX">>, <<"vcard-temp">>}, {<<"SUFFIX">>, <<"vcard-temp">>}, {<<"PREFIX">>, <<"vcard-temp">>}, {<<"MIDDLE">>, <<"vcard-temp">>}, {<<"GIVEN">>, <<"vcard-temp">>}, {<<"FAMILY">>, <<"vcard-temp">>}, {<<"X400">>, <<"vcard-temp">>}, {<<"INTERNET">>, <<"vcard-temp">>}, {<<"PREF">>, <<"vcard-temp">>}, {<<"INTL">>, <<"vcard-temp">>}, {<<"DOM">>, <<"vcard-temp">>}, {<<"PARCEL">>, <<"vcard-temp">>}, {<<"POSTAL">>, <<"vcard-temp">>}, {<<"PCS">>, <<"vcard-temp">>}, {<<"ISDN">>, <<"vcard-temp">>}, {<<"MODEM">>, <<"vcard-temp">>}, {<<"BBS">>, <<"vcard-temp">>}, {<<"VIDEO">>, <<"vcard-temp">>}, {<<"CELL">>, <<"vcard-temp">>}, {<<"MSG">>, <<"vcard-temp">>}, {<<"PAGER">>, <<"vcard-temp">>}, {<<"FAX">>, <<"vcard-temp">>}, {<<"VOICE">>, <<"vcard-temp">>}, {<<"WORK">>, <<"vcard-temp">>}, {<<"HOME">>, <<"vcard-temp">>}]. do_encode({vcard_name, _, _, _, _, _} = N, TopXMLNS) -> encode_vcard_N(N, TopXMLNS); do_encode({vcard_adr, _, _, _, _, _, _, _, _, _, _, _, _, _, _} = Adr, TopXMLNS) -> encode_vcard_ADR(Adr, TopXMLNS); do_encode({vcard_label, _, _, _, _, _, _, _, _} = Label, TopXMLNS) -> encode_vcard_LABEL(Label, TopXMLNS); do_encode({vcard_tel, _, _, _, _, _, _, _, _, _, _, _, _, _, _} = Tel, TopXMLNS) -> encode_vcard_TEL(Tel, TopXMLNS); do_encode({vcard_email, _, _, _, _, _, _} = Email, TopXMLNS) -> encode_vcard_EMAIL(Email, TopXMLNS); do_encode({vcard_geo, _, _} = Geo, TopXMLNS) -> encode_vcard_GEO(Geo, TopXMLNS); do_encode({vcard_logo, _, _, _} = Logo, TopXMLNS) -> encode_vcard_LOGO(Logo, TopXMLNS); do_encode({vcard_photo, _, _, _} = Photo, TopXMLNS) -> encode_vcard_PHOTO(Photo, TopXMLNS); do_encode({vcard_org, _, _} = Org, TopXMLNS) -> encode_vcard_ORG(Org, TopXMLNS); do_encode({vcard_sound, _, _, _} = Sound, TopXMLNS) -> encode_vcard_SOUND(Sound, TopXMLNS); do_encode({vcard_key, _, _} = Key, TopXMLNS) -> encode_vcard_KEY(Key, TopXMLNS); do_encode({vcard_temp, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} = Vcard, TopXMLNS) -> encode_vcard_temp(Vcard, TopXMLNS). do_get_name({vcard_adr, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"ADR">>; do_get_name({vcard_email, _, _, _, _, _, _}) -> <<"EMAIL">>; do_get_name({vcard_geo, _, _}) -> <<"GEO">>; do_get_name({vcard_key, _, _}) -> <<"KEY">>; do_get_name({vcard_label, _, _, _, _, _, _, _, _}) -> <<"LABEL">>; do_get_name({vcard_logo, _, _, _}) -> <<"LOGO">>; do_get_name({vcard_name, _, _, _, _, _}) -> <<"N">>; do_get_name({vcard_org, _, _}) -> <<"ORG">>; do_get_name({vcard_photo, _, _, _}) -> <<"PHOTO">>; do_get_name({vcard_sound, _, _, _}) -> <<"SOUND">>; do_get_name({vcard_tel, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"TEL">>; do_get_name({vcard_temp, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"vCard">>. do_get_ns({vcard_adr, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_email, _, _, _, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_geo, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_key, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_label, _, _, _, _, _, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_logo, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_name, _, _, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_org, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_photo, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_sound, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_tel, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"vcard-temp">>; do_get_ns({vcard_temp, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"vcard-temp">>. pp(vcard_name, 5) -> [family, given, middle, prefix, suffix]; pp(vcard_adr, 14) -> [home, work, postal, parcel, dom, intl, pref, pobox, extadd, street, locality, region, pcode, ctry]; pp(vcard_label, 8) -> [home, work, postal, parcel, dom, intl, pref, line]; pp(vcard_tel, 14) -> [home, work, voice, fax, pager, msg, cell, video, bbs, modem, isdn, pcs, pref, number]; pp(vcard_email, 6) -> [home, work, internet, pref, x400, userid]; pp(vcard_geo, 2) -> [lat, lon]; pp(vcard_logo, 3) -> [type, binval, extval]; pp(vcard_photo, 3) -> [type, binval, extval]; pp(vcard_org, 2) -> [name, units]; pp(vcard_sound, 3) -> [phonetic, binval, extval]; pp(vcard_key, 2) -> [type, cred]; pp(vcard_temp, 29) -> [version, fn, n, nickname, photo, bday, adr, label, tel, email, jabberid, mailer, tz, geo, title, role, logo, org, categories, note, prodid, rev, sort_string, sound, uid, url, class, key, desc]; pp(_, _) -> no. records() -> [{vcard_name, 5}, {vcard_adr, 14}, {vcard_label, 8}, {vcard_tel, 14}, {vcard_email, 6}, {vcard_geo, 2}, {vcard_logo, 3}, {vcard_photo, 3}, {vcard_org, 2}, {vcard_sound, 3}, {vcard_key, 2}, {vcard_temp, 29}]. decode_vcard_temp(__TopXMLNS, __Opts, {xmlel, <<"vCard">>, _attrs, _els}) -> {Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo} = decode_vcard_temp_els(__TopXMLNS, __Opts, _els, undefined, [], undefined, [], undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, [], [], [], undefined, undefined, undefined, undefined, undefined, undefined), {vcard_temp, Version, Fn, N, Nickname, Photo, Bday, Adr, Label, Tel, Email, Jabberid, Mailer, Tz, Geo, Title, Role, Logo, Org, Categories, Note, Prodid, Rev, Sort_string, Sound, Uid, Url, Class, Key, Desc}. decode_vcard_temp_els(__TopXMLNS, __Opts, [], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> {Mailer, lists:reverse(Adr), Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, lists:reverse(Email), lists:reverse(Tel), lists:reverse(Label), Fn, Version, N, Photo, Logo, Geo}; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"N">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, decode_vcard_N(<<"vcard-temp">>, __Opts, _el), Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"ADR">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, [decode_vcard_ADR(<<"vcard-temp">>, __Opts, _el) | Adr], Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"LABEL">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, [decode_vcard_LABEL(<<"vcard-temp">>, __Opts, _el) | Label], Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"TEL">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, [decode_vcard_TEL(<<"vcard-temp">>, __Opts, _el) | Tel], Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"EMAIL">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, [decode_vcard_EMAIL(<<"vcard-temp">>, __Opts, _el) | Email], Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"GEO">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, decode_vcard_GEO(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"LOGO">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, decode_vcard_LOGO(<<"vcard-temp">>, __Opts, _el), Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"PHOTO">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, decode_vcard_PHOTO(<<"vcard-temp">>, __Opts, _el), Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"ORG">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, decode_vcard_ORG(<<"vcard-temp">>, __Opts, _el), Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"SOUND">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, decode_vcard_SOUND(<<"vcard-temp">>, __Opts, _el), Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"KEY">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, decode_vcard_KEY(<<"vcard-temp">>, __Opts, _el), Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"VERSION">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, decode_vcard_VERSION(<<"vcard-temp">>, __Opts, _el), N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"FN">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, decode_vcard_FN(<<"vcard-temp">>, __Opts, _el), Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"NICKNAME">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, decode_vcard_NICKNAME(<<"vcard-temp">>, __Opts, _el), Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"BDAY">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, decode_vcard_BDAY(<<"vcard-temp">>, __Opts, _el), Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"JABBERID">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, decode_vcard_JABBERID(<<"vcard-temp">>, __Opts, _el), Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"MAILER">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, decode_vcard_MAILER(<<"vcard-temp">>, __Opts, _el), Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"TZ">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, decode_vcard_TZ(<<"vcard-temp">>, __Opts, _el), Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"TITLE">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, decode_vcard_TITLE(<<"vcard-temp">>, __Opts, _el), Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"ROLE">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, decode_vcard_ROLE(<<"vcard-temp">>, __Opts, _el), Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"NOTE">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, decode_vcard_NOTE(<<"vcard-temp">>, __Opts, _el), Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"PRODID">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, decode_vcard_PRODID(<<"vcard-temp">>, __Opts, _el), Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"REV">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, decode_vcard_REV(<<"vcard-temp">>, __Opts, _el), Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"SORT-STRING">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, decode_vcard_SORT_STRING(<<"vcard-temp">>, __Opts, _el), Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"UID">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, decode_vcard_UID(<<"vcard-temp">>, __Opts, _el), Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"URL">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, decode_vcard_URL(<<"vcard-temp">>, __Opts, _el), Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"DESC">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, decode_vcard_DESC(<<"vcard-temp">>, __Opts, _el), Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"CATEGORIES">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, decode_vcard_CATEGORIES(<<"vcard-temp">>, __Opts, _el), Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [{xmlel, <<"CLASS">>, _attrs, _} = _el | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, decode_vcard_CLASS(<<"vcard-temp">>, __Opts, _el), Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo); _ -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) end; decode_vcard_temp_els(__TopXMLNS, __Opts, [_ | _els], Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo) -> decode_vcard_temp_els(__TopXMLNS, __Opts, _els, Mailer, Adr, Class, Categories, Desc, Uid, Prodid, Jabberid, Sound, Note, Role, Title, Nickname, Rev, Sort_string, Org, Bday, Key, Tz, Url, Email, Tel, Label, Fn, Version, N, Photo, Logo, Geo). encode_vcard_temp({vcard_temp, Version, Fn, N, Nickname, Photo, Bday, Adr, Label, Tel, Email, Jabberid, Mailer, Tz, Geo, Title, Role, Logo, Org, Categories, Note, Prodid, Rev, Sort_string, Sound, Uid, Url, Class, Key, Desc}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_temp_$mailer'(Mailer, __NewTopXMLNS, 'encode_vcard_temp_$adr'(Adr, __NewTopXMLNS, 'encode_vcard_temp_$class'(Class, __NewTopXMLNS, 'encode_vcard_temp_$categories'(Categories, __NewTopXMLNS, 'encode_vcard_temp_$desc'(Desc, __NewTopXMLNS, 'encode_vcard_temp_$uid'(Uid, __NewTopXMLNS, 'encode_vcard_temp_$prodid'(Prodid, __NewTopXMLNS, 'encode_vcard_temp_$jabberid'(Jabberid, __NewTopXMLNS, 'encode_vcard_temp_$sound'(Sound, __NewTopXMLNS, 'encode_vcard_temp_$note'(Note, __NewTopXMLNS, 'encode_vcard_temp_$role'(Role, __NewTopXMLNS, 'encode_vcard_temp_$title'(Title, __NewTopXMLNS, 'encode_vcard_temp_$nickname'(Nickname, __NewTopXMLNS, 'encode_vcard_temp_$rev'(Rev, __NewTopXMLNS, 'encode_vcard_temp_$sort_string'(Sort_string, __NewTopXMLNS, 'encode_vcard_temp_$org'(Org, __NewTopXMLNS, 'encode_vcard_temp_$bday'(Bday, __NewTopXMLNS, 'encode_vcard_temp_$key'(Key, __NewTopXMLNS, 'encode_vcard_temp_$tz'(Tz, __NewTopXMLNS, 'encode_vcard_temp_$url'(Url, __NewTopXMLNS, 'encode_vcard_temp_$email'(Email, __NewTopXMLNS, 'encode_vcard_temp_$tel'(Tel, __NewTopXMLNS, 'encode_vcard_temp_$label'(Label, __NewTopXMLNS, 'encode_vcard_temp_$fn'(Fn, __NewTopXMLNS, 'encode_vcard_temp_$version'(Version, __NewTopXMLNS, 'encode_vcard_temp_$n'(N, __NewTopXMLNS, 'encode_vcard_temp_$photo'(Photo, __NewTopXMLNS, 'encode_vcard_temp_$logo'(Logo, __NewTopXMLNS, 'encode_vcard_temp_$geo'(Geo, __NewTopXMLNS, [])))))))))))))))))))))))))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"vCard">>, _attrs, _els}. 'encode_vcard_temp_$mailer'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$mailer'(Mailer, __TopXMLNS, _acc) -> [encode_vcard_MAILER(Mailer, __TopXMLNS) | _acc]. 'encode_vcard_temp_$adr'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$adr'([Adr | _els], __TopXMLNS, _acc) -> 'encode_vcard_temp_$adr'(_els, __TopXMLNS, [encode_vcard_ADR(Adr, __TopXMLNS) | _acc]). 'encode_vcard_temp_$class'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$class'(Class, __TopXMLNS, _acc) -> [encode_vcard_CLASS(Class, __TopXMLNS) | _acc]. 'encode_vcard_temp_$categories'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$categories'(Categories, __TopXMLNS, _acc) -> [encode_vcard_CATEGORIES(Categories, __TopXMLNS) | _acc]. 'encode_vcard_temp_$desc'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$desc'(Desc, __TopXMLNS, _acc) -> [encode_vcard_DESC(Desc, __TopXMLNS) | _acc]. 'encode_vcard_temp_$uid'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$uid'(Uid, __TopXMLNS, _acc) -> [encode_vcard_UID(Uid, __TopXMLNS) | _acc]. 'encode_vcard_temp_$prodid'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$prodid'(Prodid, __TopXMLNS, _acc) -> [encode_vcard_PRODID(Prodid, __TopXMLNS) | _acc]. 'encode_vcard_temp_$jabberid'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$jabberid'(Jabberid, __TopXMLNS, _acc) -> [encode_vcard_JABBERID(Jabberid, __TopXMLNS) | _acc]. 'encode_vcard_temp_$sound'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$sound'(Sound, __TopXMLNS, _acc) -> [encode_vcard_SOUND(Sound, __TopXMLNS) | _acc]. 'encode_vcard_temp_$note'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$note'(Note, __TopXMLNS, _acc) -> [encode_vcard_NOTE(Note, __TopXMLNS) | _acc]. 'encode_vcard_temp_$role'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$role'(Role, __TopXMLNS, _acc) -> [encode_vcard_ROLE(Role, __TopXMLNS) | _acc]. 'encode_vcard_temp_$title'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$title'(Title, __TopXMLNS, _acc) -> [encode_vcard_TITLE(Title, __TopXMLNS) | _acc]. 'encode_vcard_temp_$nickname'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$nickname'(Nickname, __TopXMLNS, _acc) -> [encode_vcard_NICKNAME(Nickname, __TopXMLNS) | _acc]. 'encode_vcard_temp_$rev'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$rev'(Rev, __TopXMLNS, _acc) -> [encode_vcard_REV(Rev, __TopXMLNS) | _acc]. 'encode_vcard_temp_$sort_string'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$sort_string'(Sort_string, __TopXMLNS, _acc) -> [encode_vcard_SORT_STRING(Sort_string, __TopXMLNS) | _acc]. 'encode_vcard_temp_$org'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$org'(Org, __TopXMLNS, _acc) -> [encode_vcard_ORG(Org, __TopXMLNS) | _acc]. 'encode_vcard_temp_$bday'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$bday'(Bday, __TopXMLNS, _acc) -> [encode_vcard_BDAY(Bday, __TopXMLNS) | _acc]. 'encode_vcard_temp_$key'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$key'(Key, __TopXMLNS, _acc) -> [encode_vcard_KEY(Key, __TopXMLNS) | _acc]. 'encode_vcard_temp_$tz'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$tz'(Tz, __TopXMLNS, _acc) -> [encode_vcard_TZ(Tz, __TopXMLNS) | _acc]. 'encode_vcard_temp_$url'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$url'(Url, __TopXMLNS, _acc) -> [encode_vcard_URL(Url, __TopXMLNS) | _acc]. 'encode_vcard_temp_$email'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$email'([Email | _els], __TopXMLNS, _acc) -> 'encode_vcard_temp_$email'(_els, __TopXMLNS, [encode_vcard_EMAIL(Email, __TopXMLNS) | _acc]). 'encode_vcard_temp_$tel'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$tel'([Tel | _els], __TopXMLNS, _acc) -> 'encode_vcard_temp_$tel'(_els, __TopXMLNS, [encode_vcard_TEL(Tel, __TopXMLNS) | _acc]). 'encode_vcard_temp_$label'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$label'([Label | _els], __TopXMLNS, _acc) -> 'encode_vcard_temp_$label'(_els, __TopXMLNS, [encode_vcard_LABEL(Label, __TopXMLNS) | _acc]). 'encode_vcard_temp_$fn'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$fn'(Fn, __TopXMLNS, _acc) -> [encode_vcard_FN(Fn, __TopXMLNS) | _acc]. 'encode_vcard_temp_$version'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$version'(Version, __TopXMLNS, _acc) -> [encode_vcard_VERSION(Version, __TopXMLNS) | _acc]. 'encode_vcard_temp_$n'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$n'(N, __TopXMLNS, _acc) -> [encode_vcard_N(N, __TopXMLNS) | _acc]. 'encode_vcard_temp_$photo'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$photo'(Photo, __TopXMLNS, _acc) -> [encode_vcard_PHOTO(Photo, __TopXMLNS) | _acc]. 'encode_vcard_temp_$logo'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$logo'(Logo, __TopXMLNS, _acc) -> [encode_vcard_LOGO(Logo, __TopXMLNS) | _acc]. 'encode_vcard_temp_$geo'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_temp_$geo'(Geo, __TopXMLNS, _acc) -> [encode_vcard_GEO(Geo, __TopXMLNS) | _acc]. decode_vcard_CLASS(__TopXMLNS, __Opts, {xmlel, <<"CLASS">>, _attrs, _els}) -> Class = decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, undefined), Class. decode_vcard_CLASS_els(__TopXMLNS, __Opts, [], Class) -> Class; decode_vcard_CLASS_els(__TopXMLNS, __Opts, [{xmlel, <<"PUBLIC">>, _attrs, _} = _el | _els], Class) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, decode_vcard_PUBLIC(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, Class) end; decode_vcard_CLASS_els(__TopXMLNS, __Opts, [{xmlel, <<"PRIVATE">>, _attrs, _} = _el | _els], Class) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, decode_vcard_PRIVATE(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, Class) end; decode_vcard_CLASS_els(__TopXMLNS, __Opts, [{xmlel, <<"CONFIDENTIAL">>, _attrs, _} = _el | _els], Class) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, decode_vcard_CONFIDENTIAL(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, Class) end; decode_vcard_CLASS_els(__TopXMLNS, __Opts, [_ | _els], Class) -> decode_vcard_CLASS_els(__TopXMLNS, __Opts, _els, Class). encode_vcard_CLASS(Class, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_CLASS_$class'(Class, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"CLASS">>, _attrs, _els}. 'encode_vcard_CLASS_$class'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_CLASS_$class'(public = Class, __TopXMLNS, _acc) -> [encode_vcard_PUBLIC(Class, __TopXMLNS) | _acc]; 'encode_vcard_CLASS_$class'(private = Class, __TopXMLNS, _acc) -> [encode_vcard_PRIVATE(Class, __TopXMLNS) | _acc]; 'encode_vcard_CLASS_$class'(confidential = Class, __TopXMLNS, _acc) -> [encode_vcard_CONFIDENTIAL(Class, __TopXMLNS) | _acc]. decode_vcard_CATEGORIES(__TopXMLNS, __Opts, {xmlel, <<"CATEGORIES">>, _attrs, _els}) -> Keywords = decode_vcard_CATEGORIES_els(__TopXMLNS, __Opts, _els, []), Keywords. decode_vcard_CATEGORIES_els(__TopXMLNS, __Opts, [], Keywords) -> lists:reverse(Keywords); decode_vcard_CATEGORIES_els(__TopXMLNS, __Opts, [{xmlel, <<"KEYWORD">>, _attrs, _} = _el | _els], Keywords) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_CATEGORIES_els(__TopXMLNS, __Opts, _els, [decode_vcard_KEYWORD(<<"vcard-temp">>, __Opts, _el) | Keywords]); _ -> decode_vcard_CATEGORIES_els(__TopXMLNS, __Opts, _els, Keywords) end; decode_vcard_CATEGORIES_els(__TopXMLNS, __Opts, [_ | _els], Keywords) -> decode_vcard_CATEGORIES_els(__TopXMLNS, __Opts, _els, Keywords). encode_vcard_CATEGORIES(Keywords, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_CATEGORIES_$keywords'(Keywords, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"CATEGORIES">>, _attrs, _els}. 'encode_vcard_CATEGORIES_$keywords'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_CATEGORIES_$keywords'([Keywords | _els], __TopXMLNS, _acc) -> 'encode_vcard_CATEGORIES_$keywords'(_els, __TopXMLNS, [encode_vcard_KEYWORD(Keywords, __TopXMLNS) | _acc]). decode_vcard_KEY(__TopXMLNS, __Opts, {xmlel, <<"KEY">>, _attrs, _els}) -> {Cred, Type} = decode_vcard_KEY_els(__TopXMLNS, __Opts, _els, undefined, undefined), {vcard_key, Type, Cred}. decode_vcard_KEY_els(__TopXMLNS, __Opts, [], Cred, Type) -> {Cred, Type}; decode_vcard_KEY_els(__TopXMLNS, __Opts, [{xmlel, <<"TYPE">>, _attrs, _} = _el | _els], Cred, Type) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_KEY_els(__TopXMLNS, __Opts, _els, Cred, decode_vcard_TYPE(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_KEY_els(__TopXMLNS, __Opts, _els, Cred, Type) end; decode_vcard_KEY_els(__TopXMLNS, __Opts, [{xmlel, <<"CRED">>, _attrs, _} = _el | _els], Cred, Type) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_KEY_els(__TopXMLNS, __Opts, _els, decode_vcard_CRED(<<"vcard-temp">>, __Opts, _el), Type); _ -> decode_vcard_KEY_els(__TopXMLNS, __Opts, _els, Cred, Type) end; decode_vcard_KEY_els(__TopXMLNS, __Opts, [_ | _els], Cred, Type) -> decode_vcard_KEY_els(__TopXMLNS, __Opts, _els, Cred, Type). encode_vcard_KEY({vcard_key, Type, Cred}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_KEY_$cred'(Cred, __NewTopXMLNS, 'encode_vcard_KEY_$type'(Type, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"KEY">>, _attrs, _els}. 'encode_vcard_KEY_$cred'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_KEY_$cred'(Cred, __TopXMLNS, _acc) -> [encode_vcard_CRED(Cred, __TopXMLNS) | _acc]. 'encode_vcard_KEY_$type'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_KEY_$type'(Type, __TopXMLNS, _acc) -> [encode_vcard_TYPE(Type, __TopXMLNS) | _acc]. decode_vcard_SOUND(__TopXMLNS, __Opts, {xmlel, <<"SOUND">>, _attrs, _els}) -> {Phonetic, Extval, Binval} = decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined), {vcard_sound, Phonetic, Binval, Extval}. decode_vcard_SOUND_els(__TopXMLNS, __Opts, [], Phonetic, Extval, Binval) -> {Phonetic, Extval, Binval}; decode_vcard_SOUND_els(__TopXMLNS, __Opts, [{xmlel, <<"BINVAL">>, _attrs, _} = _el | _els], Phonetic, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, Phonetic, Extval, decode_vcard_BINVAL(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, Phonetic, Extval, Binval) end; decode_vcard_SOUND_els(__TopXMLNS, __Opts, [{xmlel, <<"EXTVAL">>, _attrs, _} = _el | _els], Phonetic, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, Phonetic, decode_vcard_EXTVAL(<<"vcard-temp">>, __Opts, _el), Binval); _ -> decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, Phonetic, Extval, Binval) end; decode_vcard_SOUND_els(__TopXMLNS, __Opts, [{xmlel, <<"PHONETIC">>, _attrs, _} = _el | _els], Phonetic, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, decode_vcard_PHONETIC(<<"vcard-temp">>, __Opts, _el), Extval, Binval); _ -> decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, Phonetic, Extval, Binval) end; decode_vcard_SOUND_els(__TopXMLNS, __Opts, [_ | _els], Phonetic, Extval, Binval) -> decode_vcard_SOUND_els(__TopXMLNS, __Opts, _els, Phonetic, Extval, Binval). encode_vcard_SOUND({vcard_sound, Phonetic, Binval, Extval}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_SOUND_$phonetic'(Phonetic, __NewTopXMLNS, 'encode_vcard_SOUND_$extval'(Extval, __NewTopXMLNS, 'encode_vcard_SOUND_$binval'(Binval, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"SOUND">>, _attrs, _els}. 'encode_vcard_SOUND_$phonetic'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_SOUND_$phonetic'(Phonetic, __TopXMLNS, _acc) -> [encode_vcard_PHONETIC(Phonetic, __TopXMLNS) | _acc]. 'encode_vcard_SOUND_$extval'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_SOUND_$extval'(Extval, __TopXMLNS, _acc) -> [encode_vcard_EXTVAL(Extval, __TopXMLNS) | _acc]. 'encode_vcard_SOUND_$binval'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_SOUND_$binval'(Binval, __TopXMLNS, _acc) -> [encode_vcard_BINVAL(Binval, __TopXMLNS) | _acc]. decode_vcard_ORG(__TopXMLNS, __Opts, {xmlel, <<"ORG">>, _attrs, _els}) -> {Units, Name} = decode_vcard_ORG_els(__TopXMLNS, __Opts, _els, [], undefined), {vcard_org, Name, Units}. decode_vcard_ORG_els(__TopXMLNS, __Opts, [], Units, Name) -> {lists:reverse(Units), Name}; decode_vcard_ORG_els(__TopXMLNS, __Opts, [{xmlel, <<"ORGNAME">>, _attrs, _} = _el | _els], Units, Name) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ORG_els(__TopXMLNS, __Opts, _els, Units, decode_vcard_ORGNAME(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_ORG_els(__TopXMLNS, __Opts, _els, Units, Name) end; decode_vcard_ORG_els(__TopXMLNS, __Opts, [{xmlel, <<"ORGUNIT">>, _attrs, _} = _el | _els], Units, Name) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ORG_els(__TopXMLNS, __Opts, _els, [decode_vcard_ORGUNIT(<<"vcard-temp">>, __Opts, _el) | Units], Name); _ -> decode_vcard_ORG_els(__TopXMLNS, __Opts, _els, Units, Name) end; decode_vcard_ORG_els(__TopXMLNS, __Opts, [_ | _els], Units, Name) -> decode_vcard_ORG_els(__TopXMLNS, __Opts, _els, Units, Name). encode_vcard_ORG({vcard_org, Name, Units}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_ORG_$units'(Units, __NewTopXMLNS, 'encode_vcard_ORG_$name'(Name, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ORG">>, _attrs, _els}. 'encode_vcard_ORG_$units'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_ORG_$units'([Units | _els], __TopXMLNS, _acc) -> 'encode_vcard_ORG_$units'(_els, __TopXMLNS, [encode_vcard_ORGUNIT(Units, __TopXMLNS) | _acc]). 'encode_vcard_ORG_$name'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ORG_$name'(Name, __TopXMLNS, _acc) -> [encode_vcard_ORGNAME(Name, __TopXMLNS) | _acc]. decode_vcard_PHOTO(__TopXMLNS, __Opts, {xmlel, <<"PHOTO">>, _attrs, _els}) -> {Type, Extval, Binval} = decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined), {vcard_photo, Type, Binval, Extval}. decode_vcard_PHOTO_els(__TopXMLNS, __Opts, [], Type, Extval, Binval) -> {Type, Extval, Binval}; decode_vcard_PHOTO_els(__TopXMLNS, __Opts, [{xmlel, <<"TYPE">>, _attrs, _} = _el | _els], Type, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, decode_vcard_TYPE(<<"vcard-temp">>, __Opts, _el), Extval, Binval); _ -> decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval) end; decode_vcard_PHOTO_els(__TopXMLNS, __Opts, [{xmlel, <<"BINVAL">>, _attrs, _} = _el | _els], Type, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, Type, Extval, decode_vcard_BINVAL(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval) end; decode_vcard_PHOTO_els(__TopXMLNS, __Opts, [{xmlel, <<"EXTVAL">>, _attrs, _} = _el | _els], Type, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, Type, decode_vcard_EXTVAL(<<"vcard-temp">>, __Opts, _el), Binval); _ -> decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval) end; decode_vcard_PHOTO_els(__TopXMLNS, __Opts, [_ | _els], Type, Extval, Binval) -> decode_vcard_PHOTO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval). encode_vcard_PHOTO({vcard_photo, Type, Binval, Extval}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_PHOTO_$type'(Type, __NewTopXMLNS, 'encode_vcard_PHOTO_$extval'(Extval, __NewTopXMLNS, 'encode_vcard_PHOTO_$binval'(Binval, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PHOTO">>, _attrs, _els}. 'encode_vcard_PHOTO_$type'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_PHOTO_$type'(Type, __TopXMLNS, _acc) -> [encode_vcard_TYPE(Type, __TopXMLNS) | _acc]. 'encode_vcard_PHOTO_$extval'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_PHOTO_$extval'(Extval, __TopXMLNS, _acc) -> [encode_vcard_EXTVAL(Extval, __TopXMLNS) | _acc]. 'encode_vcard_PHOTO_$binval'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_PHOTO_$binval'(Binval, __TopXMLNS, _acc) -> [encode_vcard_BINVAL(Binval, __TopXMLNS) | _acc]. decode_vcard_LOGO(__TopXMLNS, __Opts, {xmlel, <<"LOGO">>, _attrs, _els}) -> {Type, Extval, Binval} = decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined), {vcard_logo, Type, Binval, Extval}. decode_vcard_LOGO_els(__TopXMLNS, __Opts, [], Type, Extval, Binval) -> {Type, Extval, Binval}; decode_vcard_LOGO_els(__TopXMLNS, __Opts, [{xmlel, <<"TYPE">>, _attrs, _} = _el | _els], Type, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, decode_vcard_TYPE(<<"vcard-temp">>, __Opts, _el), Extval, Binval); _ -> decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval) end; decode_vcard_LOGO_els(__TopXMLNS, __Opts, [{xmlel, <<"BINVAL">>, _attrs, _} = _el | _els], Type, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, Type, Extval, decode_vcard_BINVAL(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval) end; decode_vcard_LOGO_els(__TopXMLNS, __Opts, [{xmlel, <<"EXTVAL">>, _attrs, _} = _el | _els], Type, Extval, Binval) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, Type, decode_vcard_EXTVAL(<<"vcard-temp">>, __Opts, _el), Binval); _ -> decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval) end; decode_vcard_LOGO_els(__TopXMLNS, __Opts, [_ | _els], Type, Extval, Binval) -> decode_vcard_LOGO_els(__TopXMLNS, __Opts, _els, Type, Extval, Binval). encode_vcard_LOGO({vcard_logo, Type, Binval, Extval}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_LOGO_$type'(Type, __NewTopXMLNS, 'encode_vcard_LOGO_$extval'(Extval, __NewTopXMLNS, 'encode_vcard_LOGO_$binval'(Binval, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"LOGO">>, _attrs, _els}. 'encode_vcard_LOGO_$type'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LOGO_$type'(Type, __TopXMLNS, _acc) -> [encode_vcard_TYPE(Type, __TopXMLNS) | _acc]. 'encode_vcard_LOGO_$extval'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LOGO_$extval'(Extval, __TopXMLNS, _acc) -> [encode_vcard_EXTVAL(Extval, __TopXMLNS) | _acc]. 'encode_vcard_LOGO_$binval'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LOGO_$binval'(Binval, __TopXMLNS, _acc) -> [encode_vcard_BINVAL(Binval, __TopXMLNS) | _acc]. decode_vcard_BINVAL(__TopXMLNS, __Opts, {xmlel, <<"BINVAL">>, _attrs, _els}) -> Cdata = decode_vcard_BINVAL_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_BINVAL_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_BINVAL_cdata(__TopXMLNS, Cdata); decode_vcard_BINVAL_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_BINVAL_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_BINVAL_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_BINVAL_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_BINVAL(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_BINVAL_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"BINVAL">>, _attrs, _els}. decode_vcard_BINVAL_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_BINVAL_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"BINVAL">>, __TopXMLNS}}); _res -> _res end. encode_vcard_BINVAL_cdata(<<>>, _acc) -> _acc; encode_vcard_BINVAL_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_vcard_GEO(__TopXMLNS, __Opts, {xmlel, <<"GEO">>, _attrs, _els}) -> {Lat, Lon} = decode_vcard_GEO_els(__TopXMLNS, __Opts, _els, undefined, undefined), {vcard_geo, Lat, Lon}. decode_vcard_GEO_els(__TopXMLNS, __Opts, [], Lat, Lon) -> {Lat, Lon}; decode_vcard_GEO_els(__TopXMLNS, __Opts, [{xmlel, <<"LAT">>, _attrs, _} = _el | _els], Lat, Lon) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_GEO_els(__TopXMLNS, __Opts, _els, decode_vcard_LAT(<<"vcard-temp">>, __Opts, _el), Lon); _ -> decode_vcard_GEO_els(__TopXMLNS, __Opts, _els, Lat, Lon) end; decode_vcard_GEO_els(__TopXMLNS, __Opts, [{xmlel, <<"LON">>, _attrs, _} = _el | _els], Lat, Lon) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_GEO_els(__TopXMLNS, __Opts, _els, Lat, decode_vcard_LON(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_GEO_els(__TopXMLNS, __Opts, _els, Lat, Lon) end; decode_vcard_GEO_els(__TopXMLNS, __Opts, [_ | _els], Lat, Lon) -> decode_vcard_GEO_els(__TopXMLNS, __Opts, _els, Lat, Lon). encode_vcard_GEO({vcard_geo, Lat, Lon}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_GEO_$lat'(Lat, __NewTopXMLNS, 'encode_vcard_GEO_$lon'(Lon, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"GEO">>, _attrs, _els}. 'encode_vcard_GEO_$lat'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_GEO_$lat'(Lat, __TopXMLNS, _acc) -> [encode_vcard_LAT(Lat, __TopXMLNS) | _acc]. 'encode_vcard_GEO_$lon'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_GEO_$lon'(Lon, __TopXMLNS, _acc) -> [encode_vcard_LON(Lon, __TopXMLNS) | _acc]. decode_vcard_EMAIL(__TopXMLNS, __Opts, {xmlel, <<"EMAIL">>, _attrs, _els}) -> {X400, Userid, Internet, Home, Pref, Work} = decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, false, undefined, false, false, false, false), {vcard_email, Home, Work, Internet, Pref, X400, Userid}. decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [], X400, Userid, Internet, Home, Pref, Work) -> {X400, Userid, Internet, Home, Pref, Work}; decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [{xmlel, <<"HOME">>, _attrs, _} = _el | _els], X400, Userid, Internet, Home, Pref, Work) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, decode_vcard_HOME(<<"vcard-temp">>, __Opts, _el), Pref, Work); _ -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, Work) end; decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [{xmlel, <<"WORK">>, _attrs, _} = _el | _els], X400, Userid, Internet, Home, Pref, Work) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, decode_vcard_WORK(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, Work) end; decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [{xmlel, <<"INTERNET">>, _attrs, _} = _el | _els], X400, Userid, Internet, Home, Pref, Work) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, decode_vcard_INTERNET(<<"vcard-temp">>, __Opts, _el), Home, Pref, Work); _ -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, Work) end; decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [{xmlel, <<"PREF">>, _attrs, _} = _el | _els], X400, Userid, Internet, Home, Pref, Work) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, decode_vcard_PREF(<<"vcard-temp">>, __Opts, _el), Work); _ -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, Work) end; decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [{xmlel, <<"X400">>, _attrs, _} = _el | _els], X400, Userid, Internet, Home, Pref, Work) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, decode_vcard_X400(<<"vcard-temp">>, __Opts, _el), Userid, Internet, Home, Pref, Work); _ -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, Work) end; decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [{xmlel, <<"USERID">>, _attrs, _} = _el | _els], X400, Userid, Internet, Home, Pref, Work) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, decode_vcard_USERID(<<"vcard-temp">>, __Opts, _el), Internet, Home, Pref, Work); _ -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, Work) end; decode_vcard_EMAIL_els(__TopXMLNS, __Opts, [_ | _els], X400, Userid, Internet, Home, Pref, Work) -> decode_vcard_EMAIL_els(__TopXMLNS, __Opts, _els, X400, Userid, Internet, Home, Pref, Work). encode_vcard_EMAIL({vcard_email, Home, Work, Internet, Pref, X400, Userid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_EMAIL_$x400'(X400, __NewTopXMLNS, 'encode_vcard_EMAIL_$userid'(Userid, __NewTopXMLNS, 'encode_vcard_EMAIL_$internet'(Internet, __NewTopXMLNS, 'encode_vcard_EMAIL_$home'(Home, __NewTopXMLNS, 'encode_vcard_EMAIL_$pref'(Pref, __NewTopXMLNS, 'encode_vcard_EMAIL_$work'(Work, __NewTopXMLNS, []))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"EMAIL">>, _attrs, _els}. 'encode_vcard_EMAIL_$x400'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_EMAIL_$x400'(X400, __TopXMLNS, _acc) -> [encode_vcard_X400(X400, __TopXMLNS) | _acc]. 'encode_vcard_EMAIL_$userid'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_EMAIL_$userid'(Userid, __TopXMLNS, _acc) -> [encode_vcard_USERID(Userid, __TopXMLNS) | _acc]. 'encode_vcard_EMAIL_$internet'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_EMAIL_$internet'(Internet, __TopXMLNS, _acc) -> [encode_vcard_INTERNET(Internet, __TopXMLNS) | _acc]. 'encode_vcard_EMAIL_$home'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_EMAIL_$home'(Home, __TopXMLNS, _acc) -> [encode_vcard_HOME(Home, __TopXMLNS) | _acc]. 'encode_vcard_EMAIL_$pref'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_EMAIL_$pref'(Pref, __TopXMLNS, _acc) -> [encode_vcard_PREF(Pref, __TopXMLNS) | _acc]. 'encode_vcard_EMAIL_$work'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_EMAIL_$work'(Work, __TopXMLNS, _acc) -> [encode_vcard_WORK(Work, __TopXMLNS) | _acc]. decode_vcard_TEL(__TopXMLNS, __Opts, {xmlel, <<"TEL">>, _attrs, _els}) -> {Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video} = decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, undefined, false, false, false, false, false, false, false, false, false, false, false, false, false), {vcard_tel, Home, Work, Voice, Fax, Pager, Msg, Cell, Video, Bbs, Modem, Isdn, Pcs, Pref, Number}. decode_vcard_TEL_els(__TopXMLNS, __Opts, [], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> {Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video}; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"HOME">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, decode_vcard_HOME(<<"vcard-temp">>, __Opts, _el), Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"WORK">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, decode_vcard_WORK(<<"vcard-temp">>, __Opts, _el), Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"VOICE">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, decode_vcard_VOICE(<<"vcard-temp">>, __Opts, _el), Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"FAX">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, decode_vcard_FAX(<<"vcard-temp">>, __Opts, _el), Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"PAGER">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, decode_vcard_PAGER(<<"vcard-temp">>, __Opts, _el), Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"MSG">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, decode_vcard_MSG(<<"vcard-temp">>, __Opts, _el), Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"CELL">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, decode_vcard_CELL(<<"vcard-temp">>, __Opts, _el), Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"VIDEO">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, decode_vcard_VIDEO(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"BBS">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, decode_vcard_BBS(<<"vcard-temp">>, __Opts, _el), Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"MODEM">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, decode_vcard_MODEM(<<"vcard-temp">>, __Opts, _el), Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"ISDN">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, decode_vcard_ISDN(<<"vcard-temp">>, __Opts, _el), Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"PCS">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, decode_vcard_PCS(<<"vcard-temp">>, __Opts, _el), Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"PREF">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, decode_vcard_PREF(<<"vcard-temp">>, __Opts, _el), Msg, Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [{xmlel, <<"NUMBER">>, _attrs, _} = _el | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, decode_vcard_NUMBER(<<"vcard-temp">>, __Opts, _el), Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video); _ -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) end; decode_vcard_TEL_els(__TopXMLNS, __Opts, [_ | _els], Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video) -> decode_vcard_TEL_els(__TopXMLNS, __Opts, _els, Number, Pager, Pcs, Bbs, Voice, Home, Pref, Msg, Fax, Work, Cell, Modem, Isdn, Video). encode_vcard_TEL({vcard_tel, Home, Work, Voice, Fax, Pager, Msg, Cell, Video, Bbs, Modem, Isdn, Pcs, Pref, Number}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_TEL_$number'(Number, __NewTopXMLNS, 'encode_vcard_TEL_$pager'(Pager, __NewTopXMLNS, 'encode_vcard_TEL_$pcs'(Pcs, __NewTopXMLNS, 'encode_vcard_TEL_$bbs'(Bbs, __NewTopXMLNS, 'encode_vcard_TEL_$voice'(Voice, __NewTopXMLNS, 'encode_vcard_TEL_$home'(Home, __NewTopXMLNS, 'encode_vcard_TEL_$pref'(Pref, __NewTopXMLNS, 'encode_vcard_TEL_$msg'(Msg, __NewTopXMLNS, 'encode_vcard_TEL_$fax'(Fax, __NewTopXMLNS, 'encode_vcard_TEL_$work'(Work, __NewTopXMLNS, 'encode_vcard_TEL_$cell'(Cell, __NewTopXMLNS, 'encode_vcard_TEL_$modem'(Modem, __NewTopXMLNS, 'encode_vcard_TEL_$isdn'(Isdn, __NewTopXMLNS, 'encode_vcard_TEL_$video'(Video, __NewTopXMLNS, []))))))))))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"TEL">>, _attrs, _els}. 'encode_vcard_TEL_$number'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$number'(Number, __TopXMLNS, _acc) -> [encode_vcard_NUMBER(Number, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$pager'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$pager'(Pager, __TopXMLNS, _acc) -> [encode_vcard_PAGER(Pager, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$pcs'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$pcs'(Pcs, __TopXMLNS, _acc) -> [encode_vcard_PCS(Pcs, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$bbs'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$bbs'(Bbs, __TopXMLNS, _acc) -> [encode_vcard_BBS(Bbs, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$voice'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$voice'(Voice, __TopXMLNS, _acc) -> [encode_vcard_VOICE(Voice, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$home'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$home'(Home, __TopXMLNS, _acc) -> [encode_vcard_HOME(Home, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$pref'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$pref'(Pref, __TopXMLNS, _acc) -> [encode_vcard_PREF(Pref, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$msg'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$msg'(Msg, __TopXMLNS, _acc) -> [encode_vcard_MSG(Msg, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$fax'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$fax'(Fax, __TopXMLNS, _acc) -> [encode_vcard_FAX(Fax, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$work'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$work'(Work, __TopXMLNS, _acc) -> [encode_vcard_WORK(Work, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$cell'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$cell'(Cell, __TopXMLNS, _acc) -> [encode_vcard_CELL(Cell, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$modem'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$modem'(Modem, __TopXMLNS, _acc) -> [encode_vcard_MODEM(Modem, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$isdn'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$isdn'(Isdn, __TopXMLNS, _acc) -> [encode_vcard_ISDN(Isdn, __TopXMLNS) | _acc]. 'encode_vcard_TEL_$video'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_TEL_$video'(Video, __TopXMLNS, _acc) -> [encode_vcard_VIDEO(Video, __TopXMLNS) | _acc]. decode_vcard_LABEL(__TopXMLNS, __Opts, {xmlel, <<"LABEL">>, _attrs, _els}) -> {Line, Home, Pref, Work, Intl, Parcel, Postal, Dom} = decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, [], false, false, false, false, false, false, false), {vcard_label, Home, Work, Postal, Parcel, Dom, Intl, Pref, Line}. decode_vcard_LABEL_els(__TopXMLNS, __Opts, [], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> {lists:reverse(Line), Home, Pref, Work, Intl, Parcel, Postal, Dom}; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"HOME">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, decode_vcard_HOME(<<"vcard-temp">>, __Opts, _el), Pref, Work, Intl, Parcel, Postal, Dom); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"WORK">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, decode_vcard_WORK(<<"vcard-temp">>, __Opts, _el), Intl, Parcel, Postal, Dom); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"POSTAL">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, decode_vcard_POSTAL(<<"vcard-temp">>, __Opts, _el), Dom); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"PARCEL">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, decode_vcard_PARCEL(<<"vcard-temp">>, __Opts, _el), Postal, Dom); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"DOM">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, decode_vcard_DOM(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"INTL">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, decode_vcard_INTL(<<"vcard-temp">>, __Opts, _el), Parcel, Postal, Dom); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"PREF">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, decode_vcard_PREF(<<"vcard-temp">>, __Opts, _el), Work, Intl, Parcel, Postal, Dom); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [{xmlel, <<"LINE">>, _attrs, _} = _el | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, [decode_vcard_LINE(<<"vcard-temp">>, __Opts, _el) | Line], Home, Pref, Work, Intl, Parcel, Postal, Dom); _ -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) end; decode_vcard_LABEL_els(__TopXMLNS, __Opts, [_ | _els], Line, Home, Pref, Work, Intl, Parcel, Postal, Dom) -> decode_vcard_LABEL_els(__TopXMLNS, __Opts, _els, Line, Home, Pref, Work, Intl, Parcel, Postal, Dom). encode_vcard_LABEL({vcard_label, Home, Work, Postal, Parcel, Dom, Intl, Pref, Line}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_LABEL_$line'(Line, __NewTopXMLNS, 'encode_vcard_LABEL_$home'(Home, __NewTopXMLNS, 'encode_vcard_LABEL_$pref'(Pref, __NewTopXMLNS, 'encode_vcard_LABEL_$work'(Work, __NewTopXMLNS, 'encode_vcard_LABEL_$intl'(Intl, __NewTopXMLNS, 'encode_vcard_LABEL_$parcel'(Parcel, __NewTopXMLNS, 'encode_vcard_LABEL_$postal'(Postal, __NewTopXMLNS, 'encode_vcard_LABEL_$dom'(Dom, __NewTopXMLNS, []))))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"LABEL">>, _attrs, _els}. 'encode_vcard_LABEL_$line'([], __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$line'([Line | _els], __TopXMLNS, _acc) -> 'encode_vcard_LABEL_$line'(_els, __TopXMLNS, [encode_vcard_LINE(Line, __TopXMLNS) | _acc]). 'encode_vcard_LABEL_$home'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$home'(Home, __TopXMLNS, _acc) -> [encode_vcard_HOME(Home, __TopXMLNS) | _acc]. 'encode_vcard_LABEL_$pref'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$pref'(Pref, __TopXMLNS, _acc) -> [encode_vcard_PREF(Pref, __TopXMLNS) | _acc]. 'encode_vcard_LABEL_$work'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$work'(Work, __TopXMLNS, _acc) -> [encode_vcard_WORK(Work, __TopXMLNS) | _acc]. 'encode_vcard_LABEL_$intl'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$intl'(Intl, __TopXMLNS, _acc) -> [encode_vcard_INTL(Intl, __TopXMLNS) | _acc]. 'encode_vcard_LABEL_$parcel'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$parcel'(Parcel, __TopXMLNS, _acc) -> [encode_vcard_PARCEL(Parcel, __TopXMLNS) | _acc]. 'encode_vcard_LABEL_$postal'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$postal'(Postal, __TopXMLNS, _acc) -> [encode_vcard_POSTAL(Postal, __TopXMLNS) | _acc]. 'encode_vcard_LABEL_$dom'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_LABEL_$dom'(Dom, __TopXMLNS, _acc) -> [encode_vcard_DOM(Dom, __TopXMLNS) | _acc]. decode_vcard_ADR(__TopXMLNS, __Opts, {xmlel, <<"ADR">>, _attrs, _els}) -> {Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region} = decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, false, false, undefined, undefined, undefined, false, false, false, false, false, undefined), {vcard_adr, Home, Work, Postal, Parcel, Dom, Intl, Pref, Pobox, Extadd, Street, Locality, Region, Pcode, Ctry}. decode_vcard_ADR_els(__TopXMLNS, __Opts, [], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> {Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region}; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"HOME">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, decode_vcard_HOME(<<"vcard-temp">>, __Opts, _el), Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"WORK">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, decode_vcard_WORK(<<"vcard-temp">>, __Opts, _el), Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"POSTAL">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, decode_vcard_POSTAL(<<"vcard-temp">>, __Opts, _el), Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"PARCEL">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, decode_vcard_PARCEL(<<"vcard-temp">>, __Opts, _el), Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"DOM">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, decode_vcard_DOM(<<"vcard-temp">>, __Opts, _el), Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"INTL">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, decode_vcard_INTL(<<"vcard-temp">>, __Opts, _el), Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"PREF">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, decode_vcard_PREF(<<"vcard-temp">>, __Opts, _el), Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"POBOX">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, decode_vcard_POBOX(<<"vcard-temp">>, __Opts, _el), Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"EXTADD">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, decode_vcard_EXTADD(<<"vcard-temp">>, __Opts, _el), Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"STREET">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, decode_vcard_STREET(<<"vcard-temp">>, __Opts, _el), Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"LOCALITY">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, decode_vcard_LOCALITY(<<"vcard-temp">>, __Opts, _el), Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"REGION">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, decode_vcard_REGION(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"PCODE">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, decode_vcard_PCODE(<<"vcard-temp">>, __Opts, _el), Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [{xmlel, <<"CTRY">>, _attrs, _} = _el | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, decode_vcard_CTRY(<<"vcard-temp">>, __Opts, _el), Locality, Work, Intl, Parcel, Postal, Dom, Region); _ -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) end; decode_vcard_ADR_els(__TopXMLNS, __Opts, [_ | _els], Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region) -> decode_vcard_ADR_els(__TopXMLNS, __Opts, _els, Street, Extadd, Pcode, Home, Pref, Pobox, Ctry, Locality, Work, Intl, Parcel, Postal, Dom, Region). encode_vcard_ADR({vcard_adr, Home, Work, Postal, Parcel, Dom, Intl, Pref, Pobox, Extadd, Street, Locality, Region, Pcode, Ctry}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_ADR_$street'(Street, __NewTopXMLNS, 'encode_vcard_ADR_$extadd'(Extadd, __NewTopXMLNS, 'encode_vcard_ADR_$pcode'(Pcode, __NewTopXMLNS, 'encode_vcard_ADR_$home'(Home, __NewTopXMLNS, 'encode_vcard_ADR_$pref'(Pref, __NewTopXMLNS, 'encode_vcard_ADR_$pobox'(Pobox, __NewTopXMLNS, 'encode_vcard_ADR_$ctry'(Ctry, __NewTopXMLNS, 'encode_vcard_ADR_$locality'(Locality, __NewTopXMLNS, 'encode_vcard_ADR_$work'(Work, __NewTopXMLNS, 'encode_vcard_ADR_$intl'(Intl, __NewTopXMLNS, 'encode_vcard_ADR_$parcel'(Parcel, __NewTopXMLNS, 'encode_vcard_ADR_$postal'(Postal, __NewTopXMLNS, 'encode_vcard_ADR_$dom'(Dom, __NewTopXMLNS, 'encode_vcard_ADR_$region'(Region, __NewTopXMLNS, []))))))))))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ADR">>, _attrs, _els}. 'encode_vcard_ADR_$street'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$street'(Street, __TopXMLNS, _acc) -> [encode_vcard_STREET(Street, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$extadd'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$extadd'(Extadd, __TopXMLNS, _acc) -> [encode_vcard_EXTADD(Extadd, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$pcode'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$pcode'(Pcode, __TopXMLNS, _acc) -> [encode_vcard_PCODE(Pcode, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$home'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$home'(Home, __TopXMLNS, _acc) -> [encode_vcard_HOME(Home, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$pref'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$pref'(Pref, __TopXMLNS, _acc) -> [encode_vcard_PREF(Pref, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$pobox'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$pobox'(Pobox, __TopXMLNS, _acc) -> [encode_vcard_POBOX(Pobox, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$ctry'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$ctry'(Ctry, __TopXMLNS, _acc) -> [encode_vcard_CTRY(Ctry, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$locality'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$locality'(Locality, __TopXMLNS, _acc) -> [encode_vcard_LOCALITY(Locality, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$work'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$work'(Work, __TopXMLNS, _acc) -> [encode_vcard_WORK(Work, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$intl'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$intl'(Intl, __TopXMLNS, _acc) -> [encode_vcard_INTL(Intl, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$parcel'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$parcel'(Parcel, __TopXMLNS, _acc) -> [encode_vcard_PARCEL(Parcel, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$postal'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$postal'(Postal, __TopXMLNS, _acc) -> [encode_vcard_POSTAL(Postal, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$dom'(false, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$dom'(Dom, __TopXMLNS, _acc) -> [encode_vcard_DOM(Dom, __TopXMLNS) | _acc]. 'encode_vcard_ADR_$region'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_ADR_$region'(Region, __TopXMLNS, _acc) -> [encode_vcard_REGION(Region, __TopXMLNS) | _acc]. decode_vcard_N(__TopXMLNS, __Opts, {xmlel, <<"N">>, _attrs, _els}) -> {Middle, Suffix, Prefix, Family, Given} = decode_vcard_N_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined, undefined), {vcard_name, Family, Given, Middle, Prefix, Suffix}. decode_vcard_N_els(__TopXMLNS, __Opts, [], Middle, Suffix, Prefix, Family, Given) -> {Middle, Suffix, Prefix, Family, Given}; decode_vcard_N_els(__TopXMLNS, __Opts, [{xmlel, <<"FAMILY">>, _attrs, _} = _el | _els], Middle, Suffix, Prefix, Family, Given) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, decode_vcard_FAMILY(<<"vcard-temp">>, __Opts, _el), Given); _ -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, Family, Given) end; decode_vcard_N_els(__TopXMLNS, __Opts, [{xmlel, <<"GIVEN">>, _attrs, _} = _el | _els], Middle, Suffix, Prefix, Family, Given) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, Family, decode_vcard_GIVEN(<<"vcard-temp">>, __Opts, _el)); _ -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, Family, Given) end; decode_vcard_N_els(__TopXMLNS, __Opts, [{xmlel, <<"MIDDLE">>, _attrs, _} = _el | _els], Middle, Suffix, Prefix, Family, Given) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, decode_vcard_MIDDLE(<<"vcard-temp">>, __Opts, _el), Suffix, Prefix, Family, Given); _ -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, Family, Given) end; decode_vcard_N_els(__TopXMLNS, __Opts, [{xmlel, <<"PREFIX">>, _attrs, _} = _el | _els], Middle, Suffix, Prefix, Family, Given) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, decode_vcard_PREFIX(<<"vcard-temp">>, __Opts, _el), Family, Given); _ -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, Family, Given) end; decode_vcard_N_els(__TopXMLNS, __Opts, [{xmlel, <<"SUFFIX">>, _attrs, _} = _el | _els], Middle, Suffix, Prefix, Family, Given) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"vcard-temp">> -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, decode_vcard_SUFFIX(<<"vcard-temp">>, __Opts, _el), Prefix, Family, Given); _ -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, Family, Given) end; decode_vcard_N_els(__TopXMLNS, __Opts, [_ | _els], Middle, Suffix, Prefix, Family, Given) -> decode_vcard_N_els(__TopXMLNS, __Opts, _els, Middle, Suffix, Prefix, Family, Given). encode_vcard_N({vcard_name, Family, Given, Middle, Prefix, Suffix}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = lists:reverse('encode_vcard_N_$middle'(Middle, __NewTopXMLNS, 'encode_vcard_N_$suffix'(Suffix, __NewTopXMLNS, 'encode_vcard_N_$prefix'(Prefix, __NewTopXMLNS, 'encode_vcard_N_$family'(Family, __NewTopXMLNS, 'encode_vcard_N_$given'(Given, __NewTopXMLNS, [])))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"N">>, _attrs, _els}. 'encode_vcard_N_$middle'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_N_$middle'(Middle, __TopXMLNS, _acc) -> [encode_vcard_MIDDLE(Middle, __TopXMLNS) | _acc]. 'encode_vcard_N_$suffix'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_N_$suffix'(Suffix, __TopXMLNS, _acc) -> [encode_vcard_SUFFIX(Suffix, __TopXMLNS) | _acc]. 'encode_vcard_N_$prefix'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_N_$prefix'(Prefix, __TopXMLNS, _acc) -> [encode_vcard_PREFIX(Prefix, __TopXMLNS) | _acc]. 'encode_vcard_N_$family'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_N_$family'(Family, __TopXMLNS, _acc) -> [encode_vcard_FAMILY(Family, __TopXMLNS) | _acc]. 'encode_vcard_N_$given'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_vcard_N_$given'(Given, __TopXMLNS, _acc) -> [encode_vcard_GIVEN(Given, __TopXMLNS) | _acc]. decode_vcard_CONFIDENTIAL(__TopXMLNS, __Opts, {xmlel, <<"CONFIDENTIAL">>, _attrs, _els}) -> confidential. encode_vcard_CONFIDENTIAL(confidential, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"CONFIDENTIAL">>, _attrs, _els}. decode_vcard_PRIVATE(__TopXMLNS, __Opts, {xmlel, <<"PRIVATE">>, _attrs, _els}) -> private. encode_vcard_PRIVATE(private, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PRIVATE">>, _attrs, _els}. decode_vcard_PUBLIC(__TopXMLNS, __Opts, {xmlel, <<"PUBLIC">>, _attrs, _els}) -> public. encode_vcard_PUBLIC(public, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PUBLIC">>, _attrs, _els}. decode_vcard_EXTVAL(__TopXMLNS, __Opts, {xmlel, <<"EXTVAL">>, _attrs, _els}) -> Cdata = decode_vcard_EXTVAL_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_EXTVAL_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_EXTVAL_cdata(__TopXMLNS, Cdata); decode_vcard_EXTVAL_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_EXTVAL_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_EXTVAL_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_EXTVAL_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_EXTVAL(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_EXTVAL_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"EXTVAL">>, _attrs, _els}. decode_vcard_EXTVAL_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_EXTVAL_cdata(__TopXMLNS, _val) -> _val. encode_vcard_EXTVAL_cdata(<<>>, _acc) -> _acc; encode_vcard_EXTVAL_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_TYPE(__TopXMLNS, __Opts, {xmlel, <<"TYPE">>, _attrs, _els}) -> Cdata = decode_vcard_TYPE_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_TYPE_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_TYPE_cdata(__TopXMLNS, Cdata); decode_vcard_TYPE_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_TYPE_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_TYPE_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_TYPE_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_TYPE(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_TYPE_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"TYPE">>, _attrs, _els}. decode_vcard_TYPE_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_TYPE_cdata(__TopXMLNS, _val) -> _val. encode_vcard_TYPE_cdata(<<>>, _acc) -> _acc; encode_vcard_TYPE_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_DESC(__TopXMLNS, __Opts, {xmlel, <<"DESC">>, _attrs, _els}) -> Cdata = decode_vcard_DESC_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_DESC_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_DESC_cdata(__TopXMLNS, Cdata); decode_vcard_DESC_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_DESC_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_DESC_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_DESC_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_DESC(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_DESC_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"DESC">>, _attrs, _els}. decode_vcard_DESC_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_DESC_cdata(__TopXMLNS, _val) -> _val. encode_vcard_DESC_cdata(<<>>, _acc) -> _acc; encode_vcard_DESC_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_URL(__TopXMLNS, __Opts, {xmlel, <<"URL">>, _attrs, _els}) -> Cdata = decode_vcard_URL_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_URL_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_URL_cdata(__TopXMLNS, Cdata); decode_vcard_URL_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_URL_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_URL_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_URL_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_URL(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_URL_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"URL">>, _attrs, _els}. decode_vcard_URL_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_URL_cdata(__TopXMLNS, _val) -> _val. encode_vcard_URL_cdata(<<>>, _acc) -> _acc; encode_vcard_URL_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_UID(__TopXMLNS, __Opts, {xmlel, <<"UID">>, _attrs, _els}) -> Cdata = decode_vcard_UID_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_UID_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_UID_cdata(__TopXMLNS, Cdata); decode_vcard_UID_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_UID_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_UID_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_UID_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_UID(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_UID_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"UID">>, _attrs, _els}. decode_vcard_UID_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_UID_cdata(__TopXMLNS, _val) -> _val. encode_vcard_UID_cdata(<<>>, _acc) -> _acc; encode_vcard_UID_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_SORT_STRING(__TopXMLNS, __Opts, {xmlel, <<"SORT-STRING">>, _attrs, _els}) -> Cdata = decode_vcard_SORT_STRING_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_SORT_STRING_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_SORT_STRING_cdata(__TopXMLNS, Cdata); decode_vcard_SORT_STRING_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_SORT_STRING_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_SORT_STRING_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_SORT_STRING_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_SORT_STRING(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_SORT_STRING_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"SORT-STRING">>, _attrs, _els}. decode_vcard_SORT_STRING_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_SORT_STRING_cdata(__TopXMLNS, _val) -> _val. encode_vcard_SORT_STRING_cdata(<<>>, _acc) -> _acc; encode_vcard_SORT_STRING_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_REV(__TopXMLNS, __Opts, {xmlel, <<"REV">>, _attrs, _els}) -> Cdata = decode_vcard_REV_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_REV_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_REV_cdata(__TopXMLNS, Cdata); decode_vcard_REV_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_REV_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_REV_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_REV_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_REV(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_REV_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"REV">>, _attrs, _els}. decode_vcard_REV_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_REV_cdata(__TopXMLNS, _val) -> _val. encode_vcard_REV_cdata(<<>>, _acc) -> _acc; encode_vcard_REV_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_PRODID(__TopXMLNS, __Opts, {xmlel, <<"PRODID">>, _attrs, _els}) -> Cdata = decode_vcard_PRODID_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_PRODID_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_PRODID_cdata(__TopXMLNS, Cdata); decode_vcard_PRODID_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_PRODID_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_PRODID_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_PRODID_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_PRODID(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_PRODID_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PRODID">>, _attrs, _els}. decode_vcard_PRODID_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_PRODID_cdata(__TopXMLNS, _val) -> _val. encode_vcard_PRODID_cdata(<<>>, _acc) -> _acc; encode_vcard_PRODID_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_NOTE(__TopXMLNS, __Opts, {xmlel, <<"NOTE">>, _attrs, _els}) -> Cdata = decode_vcard_NOTE_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_NOTE_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_NOTE_cdata(__TopXMLNS, Cdata); decode_vcard_NOTE_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_NOTE_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_NOTE_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_NOTE_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_NOTE(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_NOTE_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"NOTE">>, _attrs, _els}. decode_vcard_NOTE_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_NOTE_cdata(__TopXMLNS, _val) -> _val. encode_vcard_NOTE_cdata(<<>>, _acc) -> _acc; encode_vcard_NOTE_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_KEYWORD(__TopXMLNS, __Opts, {xmlel, <<"KEYWORD">>, _attrs, _els}) -> Cdata = decode_vcard_KEYWORD_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_KEYWORD_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_KEYWORD_cdata(__TopXMLNS, Cdata); decode_vcard_KEYWORD_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_KEYWORD_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_KEYWORD_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_KEYWORD_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_KEYWORD(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_KEYWORD_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"KEYWORD">>, _attrs, _els}. decode_vcard_KEYWORD_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_KEYWORD_cdata(__TopXMLNS, _val) -> _val. encode_vcard_KEYWORD_cdata(<<>>, _acc) -> _acc; encode_vcard_KEYWORD_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_ROLE(__TopXMLNS, __Opts, {xmlel, <<"ROLE">>, _attrs, _els}) -> Cdata = decode_vcard_ROLE_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_ROLE_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_ROLE_cdata(__TopXMLNS, Cdata); decode_vcard_ROLE_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_ROLE_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_ROLE_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_ROLE_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_ROLE(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_ROLE_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ROLE">>, _attrs, _els}. decode_vcard_ROLE_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_ROLE_cdata(__TopXMLNS, _val) -> _val. encode_vcard_ROLE_cdata(<<>>, _acc) -> _acc; encode_vcard_ROLE_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_TITLE(__TopXMLNS, __Opts, {xmlel, <<"TITLE">>, _attrs, _els}) -> Cdata = decode_vcard_TITLE_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_TITLE_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_TITLE_cdata(__TopXMLNS, Cdata); decode_vcard_TITLE_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_TITLE_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_TITLE_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_TITLE_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_TITLE(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_TITLE_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"TITLE">>, _attrs, _els}. decode_vcard_TITLE_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_TITLE_cdata(__TopXMLNS, _val) -> _val. encode_vcard_TITLE_cdata(<<>>, _acc) -> _acc; encode_vcard_TITLE_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_TZ(__TopXMLNS, __Opts, {xmlel, <<"TZ">>, _attrs, _els}) -> Cdata = decode_vcard_TZ_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_TZ_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_TZ_cdata(__TopXMLNS, Cdata); decode_vcard_TZ_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_TZ_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_TZ_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_TZ_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_TZ(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_TZ_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"TZ">>, _attrs, _els}. decode_vcard_TZ_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_TZ_cdata(__TopXMLNS, _val) -> _val. encode_vcard_TZ_cdata(<<>>, _acc) -> _acc; encode_vcard_TZ_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_MAILER(__TopXMLNS, __Opts, {xmlel, <<"MAILER">>, _attrs, _els}) -> Cdata = decode_vcard_MAILER_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_MAILER_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_MAILER_cdata(__TopXMLNS, Cdata); decode_vcard_MAILER_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_MAILER_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_MAILER_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_MAILER_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_MAILER(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_MAILER_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"MAILER">>, _attrs, _els}. decode_vcard_MAILER_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_MAILER_cdata(__TopXMLNS, _val) -> _val. encode_vcard_MAILER_cdata(<<>>, _acc) -> _acc; encode_vcard_MAILER_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_JABBERID(__TopXMLNS, __Opts, {xmlel, <<"JABBERID">>, _attrs, _els}) -> Cdata = decode_vcard_JABBERID_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_JABBERID_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_JABBERID_cdata(__TopXMLNS, Cdata); decode_vcard_JABBERID_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_JABBERID_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_JABBERID_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_JABBERID_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_JABBERID(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_JABBERID_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"JABBERID">>, _attrs, _els}. decode_vcard_JABBERID_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_JABBERID_cdata(__TopXMLNS, _val) -> _val. encode_vcard_JABBERID_cdata(<<>>, _acc) -> _acc; encode_vcard_JABBERID_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_BDAY(__TopXMLNS, __Opts, {xmlel, <<"BDAY">>, _attrs, _els}) -> Cdata = decode_vcard_BDAY_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_BDAY_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_BDAY_cdata(__TopXMLNS, Cdata); decode_vcard_BDAY_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_BDAY_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_BDAY_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_BDAY_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_BDAY(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_BDAY_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"BDAY">>, _attrs, _els}. decode_vcard_BDAY_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_BDAY_cdata(__TopXMLNS, _val) -> _val. encode_vcard_BDAY_cdata(<<>>, _acc) -> _acc; encode_vcard_BDAY_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_NICKNAME(__TopXMLNS, __Opts, {xmlel, <<"NICKNAME">>, _attrs, _els}) -> Cdata = decode_vcard_NICKNAME_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_NICKNAME_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_NICKNAME_cdata(__TopXMLNS, Cdata); decode_vcard_NICKNAME_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_NICKNAME_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_NICKNAME_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_NICKNAME_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_NICKNAME(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_NICKNAME_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"NICKNAME">>, _attrs, _els}. decode_vcard_NICKNAME_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_NICKNAME_cdata(__TopXMLNS, _val) -> _val. encode_vcard_NICKNAME_cdata(<<>>, _acc) -> _acc; encode_vcard_NICKNAME_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_FN(__TopXMLNS, __Opts, {xmlel, <<"FN">>, _attrs, _els}) -> Cdata = decode_vcard_FN_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_FN_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_FN_cdata(__TopXMLNS, Cdata); decode_vcard_FN_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_FN_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_FN_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_FN_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_FN(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_FN_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"FN">>, _attrs, _els}. decode_vcard_FN_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_FN_cdata(__TopXMLNS, _val) -> _val. encode_vcard_FN_cdata(<<>>, _acc) -> _acc; encode_vcard_FN_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_VERSION(__TopXMLNS, __Opts, {xmlel, <<"VERSION">>, _attrs, _els}) -> Cdata = decode_vcard_VERSION_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_VERSION_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_VERSION_cdata(__TopXMLNS, Cdata); decode_vcard_VERSION_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_VERSION_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_VERSION_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_VERSION_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_VERSION(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_VERSION_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"VERSION">>, _attrs, _els}. decode_vcard_VERSION_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_VERSION_cdata(__TopXMLNS, _val) -> _val. encode_vcard_VERSION_cdata(<<>>, _acc) -> _acc; encode_vcard_VERSION_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_CRED(__TopXMLNS, __Opts, {xmlel, <<"CRED">>, _attrs, _els}) -> Cdata = decode_vcard_CRED_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_CRED_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_CRED_cdata(__TopXMLNS, Cdata); decode_vcard_CRED_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_CRED_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_CRED_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_CRED_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_CRED(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_CRED_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"CRED">>, _attrs, _els}. decode_vcard_CRED_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_CRED_cdata(__TopXMLNS, _val) -> _val. encode_vcard_CRED_cdata(<<>>, _acc) -> _acc; encode_vcard_CRED_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_PHONETIC(__TopXMLNS, __Opts, {xmlel, <<"PHONETIC">>, _attrs, _els}) -> Cdata = decode_vcard_PHONETIC_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_PHONETIC_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_PHONETIC_cdata(__TopXMLNS, Cdata); decode_vcard_PHONETIC_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_PHONETIC_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_PHONETIC_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_PHONETIC_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_PHONETIC(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_PHONETIC_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PHONETIC">>, _attrs, _els}. decode_vcard_PHONETIC_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_PHONETIC_cdata(__TopXMLNS, _val) -> _val. encode_vcard_PHONETIC_cdata(<<>>, _acc) -> _acc; encode_vcard_PHONETIC_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_ORGUNIT(__TopXMLNS, __Opts, {xmlel, <<"ORGUNIT">>, _attrs, _els}) -> Cdata = decode_vcard_ORGUNIT_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_ORGUNIT_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_ORGUNIT_cdata(__TopXMLNS, Cdata); decode_vcard_ORGUNIT_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_ORGUNIT_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_ORGUNIT_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_ORGUNIT_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_ORGUNIT(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_ORGUNIT_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ORGUNIT">>, _attrs, _els}. decode_vcard_ORGUNIT_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_ORGUNIT_cdata(__TopXMLNS, _val) -> _val. encode_vcard_ORGUNIT_cdata(<<>>, _acc) -> _acc; encode_vcard_ORGUNIT_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_ORGNAME(__TopXMLNS, __Opts, {xmlel, <<"ORGNAME">>, _attrs, _els}) -> Cdata = decode_vcard_ORGNAME_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_ORGNAME_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_ORGNAME_cdata(__TopXMLNS, Cdata); decode_vcard_ORGNAME_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_ORGNAME_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_ORGNAME_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_ORGNAME_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_ORGNAME(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_ORGNAME_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ORGNAME">>, _attrs, _els}. decode_vcard_ORGNAME_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_ORGNAME_cdata(__TopXMLNS, _val) -> _val. encode_vcard_ORGNAME_cdata(<<>>, _acc) -> _acc; encode_vcard_ORGNAME_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_LON(__TopXMLNS, __Opts, {xmlel, <<"LON">>, _attrs, _els}) -> Cdata = decode_vcard_LON_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_LON_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_LON_cdata(__TopXMLNS, Cdata); decode_vcard_LON_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_LON_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_LON_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_LON_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_LON(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_LON_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"LON">>, _attrs, _els}. decode_vcard_LON_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_LON_cdata(__TopXMLNS, _val) -> _val. encode_vcard_LON_cdata(<<>>, _acc) -> _acc; encode_vcard_LON_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_LAT(__TopXMLNS, __Opts, {xmlel, <<"LAT">>, _attrs, _els}) -> Cdata = decode_vcard_LAT_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_LAT_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_LAT_cdata(__TopXMLNS, Cdata); decode_vcard_LAT_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_LAT_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_LAT_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_LAT_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_LAT(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_LAT_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"LAT">>, _attrs, _els}. decode_vcard_LAT_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_LAT_cdata(__TopXMLNS, _val) -> _val. encode_vcard_LAT_cdata(<<>>, _acc) -> _acc; encode_vcard_LAT_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_USERID(__TopXMLNS, __Opts, {xmlel, <<"USERID">>, _attrs, _els}) -> Cdata = decode_vcard_USERID_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_USERID_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_USERID_cdata(__TopXMLNS, Cdata); decode_vcard_USERID_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_USERID_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_USERID_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_USERID_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_USERID(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_USERID_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"USERID">>, _attrs, _els}. decode_vcard_USERID_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_USERID_cdata(__TopXMLNS, _val) -> _val. encode_vcard_USERID_cdata(<<>>, _acc) -> _acc; encode_vcard_USERID_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_NUMBER(__TopXMLNS, __Opts, {xmlel, <<"NUMBER">>, _attrs, _els}) -> Cdata = decode_vcard_NUMBER_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_NUMBER_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_NUMBER_cdata(__TopXMLNS, Cdata); decode_vcard_NUMBER_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_NUMBER_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_NUMBER_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_NUMBER_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_NUMBER(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_NUMBER_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"NUMBER">>, _attrs, _els}. decode_vcard_NUMBER_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_NUMBER_cdata(__TopXMLNS, _val) -> _val. encode_vcard_NUMBER_cdata(<<>>, _acc) -> _acc; encode_vcard_NUMBER_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_LINE(__TopXMLNS, __Opts, {xmlel, <<"LINE">>, _attrs, _els}) -> Cdata = decode_vcard_LINE_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_LINE_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_LINE_cdata(__TopXMLNS, Cdata); decode_vcard_LINE_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_LINE_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_LINE_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_LINE_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_LINE(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_LINE_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"LINE">>, _attrs, _els}. decode_vcard_LINE_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_LINE_cdata(__TopXMLNS, _val) -> _val. encode_vcard_LINE_cdata(<<>>, _acc) -> _acc; encode_vcard_LINE_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_CTRY(__TopXMLNS, __Opts, {xmlel, <<"CTRY">>, _attrs, _els}) -> Cdata = decode_vcard_CTRY_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_CTRY_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_CTRY_cdata(__TopXMLNS, Cdata); decode_vcard_CTRY_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_CTRY_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_CTRY_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_CTRY_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_CTRY(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_CTRY_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"CTRY">>, _attrs, _els}. decode_vcard_CTRY_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_CTRY_cdata(__TopXMLNS, _val) -> _val. encode_vcard_CTRY_cdata(<<>>, _acc) -> _acc; encode_vcard_CTRY_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_PCODE(__TopXMLNS, __Opts, {xmlel, <<"PCODE">>, _attrs, _els}) -> Cdata = decode_vcard_PCODE_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_PCODE_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_PCODE_cdata(__TopXMLNS, Cdata); decode_vcard_PCODE_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_PCODE_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_PCODE_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_PCODE_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_PCODE(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_PCODE_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PCODE">>, _attrs, _els}. decode_vcard_PCODE_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_PCODE_cdata(__TopXMLNS, _val) -> _val. encode_vcard_PCODE_cdata(<<>>, _acc) -> _acc; encode_vcard_PCODE_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_REGION(__TopXMLNS, __Opts, {xmlel, <<"REGION">>, _attrs, _els}) -> Cdata = decode_vcard_REGION_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_REGION_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_REGION_cdata(__TopXMLNS, Cdata); decode_vcard_REGION_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_REGION_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_REGION_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_REGION_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_REGION(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_REGION_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"REGION">>, _attrs, _els}. decode_vcard_REGION_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_REGION_cdata(__TopXMLNS, _val) -> _val. encode_vcard_REGION_cdata(<<>>, _acc) -> _acc; encode_vcard_REGION_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_LOCALITY(__TopXMLNS, __Opts, {xmlel, <<"LOCALITY">>, _attrs, _els}) -> Cdata = decode_vcard_LOCALITY_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_LOCALITY_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_LOCALITY_cdata(__TopXMLNS, Cdata); decode_vcard_LOCALITY_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_LOCALITY_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_LOCALITY_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_LOCALITY_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_LOCALITY(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_LOCALITY_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"LOCALITY">>, _attrs, _els}. decode_vcard_LOCALITY_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_LOCALITY_cdata(__TopXMLNS, _val) -> _val. encode_vcard_LOCALITY_cdata(<<>>, _acc) -> _acc; encode_vcard_LOCALITY_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_STREET(__TopXMLNS, __Opts, {xmlel, <<"STREET">>, _attrs, _els}) -> Cdata = decode_vcard_STREET_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_STREET_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_STREET_cdata(__TopXMLNS, Cdata); decode_vcard_STREET_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_STREET_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_STREET_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_STREET_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_STREET(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_STREET_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"STREET">>, _attrs, _els}. decode_vcard_STREET_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_STREET_cdata(__TopXMLNS, _val) -> _val. encode_vcard_STREET_cdata(<<>>, _acc) -> _acc; encode_vcard_STREET_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_EXTADD(__TopXMLNS, __Opts, {xmlel, <<"EXTADD">>, _attrs, _els}) -> Cdata = decode_vcard_EXTADD_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_EXTADD_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_EXTADD_cdata(__TopXMLNS, Cdata); decode_vcard_EXTADD_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_EXTADD_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_EXTADD_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_EXTADD_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_EXTADD(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_EXTADD_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"EXTADD">>, _attrs, _els}. decode_vcard_EXTADD_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_EXTADD_cdata(__TopXMLNS, _val) -> _val. encode_vcard_EXTADD_cdata(<<>>, _acc) -> _acc; encode_vcard_EXTADD_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_POBOX(__TopXMLNS, __Opts, {xmlel, <<"POBOX">>, _attrs, _els}) -> Cdata = decode_vcard_POBOX_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_POBOX_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_POBOX_cdata(__TopXMLNS, Cdata); decode_vcard_POBOX_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_POBOX_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_POBOX_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_POBOX_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_POBOX(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_POBOX_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"POBOX">>, _attrs, _els}. decode_vcard_POBOX_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_POBOX_cdata(__TopXMLNS, _val) -> _val. encode_vcard_POBOX_cdata(<<>>, _acc) -> _acc; encode_vcard_POBOX_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_SUFFIX(__TopXMLNS, __Opts, {xmlel, <<"SUFFIX">>, _attrs, _els}) -> Cdata = decode_vcard_SUFFIX_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_SUFFIX_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_SUFFIX_cdata(__TopXMLNS, Cdata); decode_vcard_SUFFIX_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_SUFFIX_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_SUFFIX_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_SUFFIX_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_SUFFIX(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_SUFFIX_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"SUFFIX">>, _attrs, _els}. decode_vcard_SUFFIX_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_SUFFIX_cdata(__TopXMLNS, _val) -> _val. encode_vcard_SUFFIX_cdata(<<>>, _acc) -> _acc; encode_vcard_SUFFIX_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_PREFIX(__TopXMLNS, __Opts, {xmlel, <<"PREFIX">>, _attrs, _els}) -> Cdata = decode_vcard_PREFIX_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_PREFIX_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_PREFIX_cdata(__TopXMLNS, Cdata); decode_vcard_PREFIX_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_PREFIX_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_PREFIX_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_PREFIX_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_PREFIX(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_PREFIX_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PREFIX">>, _attrs, _els}. decode_vcard_PREFIX_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_PREFIX_cdata(__TopXMLNS, _val) -> _val. encode_vcard_PREFIX_cdata(<<>>, _acc) -> _acc; encode_vcard_PREFIX_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_MIDDLE(__TopXMLNS, __Opts, {xmlel, <<"MIDDLE">>, _attrs, _els}) -> Cdata = decode_vcard_MIDDLE_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_MIDDLE_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_MIDDLE_cdata(__TopXMLNS, Cdata); decode_vcard_MIDDLE_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_MIDDLE_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_MIDDLE_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_MIDDLE_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_MIDDLE(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_MIDDLE_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"MIDDLE">>, _attrs, _els}. decode_vcard_MIDDLE_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_MIDDLE_cdata(__TopXMLNS, _val) -> _val. encode_vcard_MIDDLE_cdata(<<>>, _acc) -> _acc; encode_vcard_MIDDLE_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_GIVEN(__TopXMLNS, __Opts, {xmlel, <<"GIVEN">>, _attrs, _els}) -> Cdata = decode_vcard_GIVEN_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_GIVEN_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_GIVEN_cdata(__TopXMLNS, Cdata); decode_vcard_GIVEN_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_GIVEN_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_GIVEN_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_GIVEN_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_GIVEN(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_GIVEN_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"GIVEN">>, _attrs, _els}. decode_vcard_GIVEN_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_GIVEN_cdata(__TopXMLNS, _val) -> _val. encode_vcard_GIVEN_cdata(<<>>, _acc) -> _acc; encode_vcard_GIVEN_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_FAMILY(__TopXMLNS, __Opts, {xmlel, <<"FAMILY">>, _attrs, _els}) -> Cdata = decode_vcard_FAMILY_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_vcard_FAMILY_els(__TopXMLNS, __Opts, [], Cdata) -> decode_vcard_FAMILY_cdata(__TopXMLNS, Cdata); decode_vcard_FAMILY_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_vcard_FAMILY_els(__TopXMLNS, __Opts, _els, <>); decode_vcard_FAMILY_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_vcard_FAMILY_els(__TopXMLNS, __Opts, _els, Cdata). encode_vcard_FAMILY(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = encode_vcard_FAMILY_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"FAMILY">>, _attrs, _els}. decode_vcard_FAMILY_cdata(__TopXMLNS, <<>>) -> <<>>; decode_vcard_FAMILY_cdata(__TopXMLNS, _val) -> _val. encode_vcard_FAMILY_cdata(<<>>, _acc) -> _acc; encode_vcard_FAMILY_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_vcard_X400(__TopXMLNS, __Opts, {xmlel, <<"X400">>, _attrs, _els}) -> true. encode_vcard_X400(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"X400">>, _attrs, _els}. decode_vcard_INTERNET(__TopXMLNS, __Opts, {xmlel, <<"INTERNET">>, _attrs, _els}) -> true. encode_vcard_INTERNET(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"INTERNET">>, _attrs, _els}. decode_vcard_PREF(__TopXMLNS, __Opts, {xmlel, <<"PREF">>, _attrs, _els}) -> true. encode_vcard_PREF(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PREF">>, _attrs, _els}. decode_vcard_INTL(__TopXMLNS, __Opts, {xmlel, <<"INTL">>, _attrs, _els}) -> true. encode_vcard_INTL(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"INTL">>, _attrs, _els}. decode_vcard_DOM(__TopXMLNS, __Opts, {xmlel, <<"DOM">>, _attrs, _els}) -> true. encode_vcard_DOM(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"DOM">>, _attrs, _els}. decode_vcard_PARCEL(__TopXMLNS, __Opts, {xmlel, <<"PARCEL">>, _attrs, _els}) -> true. encode_vcard_PARCEL(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PARCEL">>, _attrs, _els}. decode_vcard_POSTAL(__TopXMLNS, __Opts, {xmlel, <<"POSTAL">>, _attrs, _els}) -> true. encode_vcard_POSTAL(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"POSTAL">>, _attrs, _els}. decode_vcard_PCS(__TopXMLNS, __Opts, {xmlel, <<"PCS">>, _attrs, _els}) -> true. encode_vcard_PCS(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PCS">>, _attrs, _els}. decode_vcard_ISDN(__TopXMLNS, __Opts, {xmlel, <<"ISDN">>, _attrs, _els}) -> true. encode_vcard_ISDN(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ISDN">>, _attrs, _els}. decode_vcard_MODEM(__TopXMLNS, __Opts, {xmlel, <<"MODEM">>, _attrs, _els}) -> true. encode_vcard_MODEM(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"MODEM">>, _attrs, _els}. decode_vcard_BBS(__TopXMLNS, __Opts, {xmlel, <<"BBS">>, _attrs, _els}) -> true. encode_vcard_BBS(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"BBS">>, _attrs, _els}. decode_vcard_VIDEO(__TopXMLNS, __Opts, {xmlel, <<"VIDEO">>, _attrs, _els}) -> true. encode_vcard_VIDEO(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"VIDEO">>, _attrs, _els}. decode_vcard_CELL(__TopXMLNS, __Opts, {xmlel, <<"CELL">>, _attrs, _els}) -> true. encode_vcard_CELL(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"CELL">>, _attrs, _els}. decode_vcard_MSG(__TopXMLNS, __Opts, {xmlel, <<"MSG">>, _attrs, _els}) -> true. encode_vcard_MSG(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"MSG">>, _attrs, _els}. decode_vcard_PAGER(__TopXMLNS, __Opts, {xmlel, <<"PAGER">>, _attrs, _els}) -> true. encode_vcard_PAGER(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"PAGER">>, _attrs, _els}. decode_vcard_FAX(__TopXMLNS, __Opts, {xmlel, <<"FAX">>, _attrs, _els}) -> true. encode_vcard_FAX(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"FAX">>, _attrs, _els}. decode_vcard_VOICE(__TopXMLNS, __Opts, {xmlel, <<"VOICE">>, _attrs, _els}) -> true. encode_vcard_VOICE(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"VOICE">>, _attrs, _els}. decode_vcard_WORK(__TopXMLNS, __Opts, {xmlel, <<"WORK">>, _attrs, _els}) -> true. encode_vcard_WORK(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"WORK">>, _attrs, _els}. decode_vcard_HOME(__TopXMLNS, __Opts, {xmlel, <<"HOME">>, _attrs, _els}) -> true. encode_vcard_HOME(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"vcard-temp">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"HOME">>, _attrs, _els}. xmpp-1.4.4/src/xep0158.erl0000644000232200023220000000410413610066730015460 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0158). -compile(export_all). do_decode(<<"captcha">>, <<"urn:xmpp:captcha">>, El, Opts) -> decode_captcha(<<"urn:xmpp:captcha">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"captcha">>, <<"urn:xmpp:captcha">>}]. do_encode({xcaptcha, _} = Captcha, TopXMLNS) -> encode_captcha(Captcha, TopXMLNS). do_get_name({xcaptcha, _}) -> <<"captcha">>. do_get_ns({xcaptcha, _}) -> <<"urn:xmpp:captcha">>. pp(xcaptcha, 1) -> [xdata]; pp(_, _) -> no. records() -> [{xcaptcha, 1}]. decode_captcha(__TopXMLNS, __Opts, {xmlel, <<"captcha">>, _attrs, _els}) -> Xdata = decode_captcha_els(__TopXMLNS, __Opts, _els, error), {xcaptcha, Xdata}. decode_captcha_els(__TopXMLNS, __Opts, [], Xdata) -> case Xdata of error -> erlang:error({xmpp_codec, {missing_tag, <<"x">>, __TopXMLNS}}); {value, Xdata1} -> Xdata1 end; decode_captcha_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_captcha_els(__TopXMLNS, __Opts, _els, {value, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)}); _ -> decode_captcha_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_captcha_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_captcha_els(__TopXMLNS, __Opts, _els, Xdata). encode_captcha({xcaptcha, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:captcha">>, [], __TopXMLNS), _els = lists:reverse('encode_captcha_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"captcha">>, _attrs, _els}. 'encode_captcha_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. xmpp-1.4.4/src/xep0166.erl0000644000232200023220000013612413610066730015467 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0166). -compile(export_all). do_decode(<<"jingle">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"content">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_content(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"reason">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"text">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_text(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"unsupported-transports">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_unsupported_transports(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"unsupported-applications">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_unsupported_applications(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"timeout">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_timeout(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"success">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_success(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"security-error">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_security_error(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"media-error">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_media_error(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"incompatible-parameters">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_incompatible_parameters(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"gone">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_gone(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"general-error">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_general_error(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"failed-transport">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_failed_transport(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"failed-application">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_failed_application(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"expired">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_expired(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"decline">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_decline(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"connectivity-error">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_connectivity_error(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"cancel">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_cancel(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"busy">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_busy(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"alternative-session">>, <<"urn:xmpp:jingle:1">>, El, Opts) -> decode_jingle_reason_alternative_session(<<"urn:xmpp:jingle:1">>, Opts, El); do_decode(<<"security-required">>, <<"urn:xmpp:jingle:errors:1">>, El, Opts) -> decode_jingle_error_security_required(<<"urn:xmpp:jingle:errors:1">>, Opts, El); do_decode(<<"unsupported-info">>, <<"urn:xmpp:jingle:errors:1">>, El, Opts) -> decode_jingle_error_unsupported_info(<<"urn:xmpp:jingle:errors:1">>, Opts, El); do_decode(<<"unknown-session">>, <<"urn:xmpp:jingle:errors:1">>, El, Opts) -> decode_jingle_error_unknown_session(<<"urn:xmpp:jingle:errors:1">>, Opts, El); do_decode(<<"tie-break">>, <<"urn:xmpp:jingle:errors:1">>, El, Opts) -> decode_jingle_error_tie_break(<<"urn:xmpp:jingle:errors:1">>, Opts, El); do_decode(<<"out-of-order">>, <<"urn:xmpp:jingle:errors:1">>, El, Opts) -> decode_jingle_error_out_of_order(<<"urn:xmpp:jingle:errors:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"jingle">>, <<"urn:xmpp:jingle:1">>}, {<<"content">>, <<"urn:xmpp:jingle:1">>}, {<<"reason">>, <<"urn:xmpp:jingle:1">>}, {<<"text">>, <<"urn:xmpp:jingle:1">>}, {<<"unsupported-transports">>, <<"urn:xmpp:jingle:1">>}, {<<"unsupported-applications">>, <<"urn:xmpp:jingle:1">>}, {<<"timeout">>, <<"urn:xmpp:jingle:1">>}, {<<"success">>, <<"urn:xmpp:jingle:1">>}, {<<"security-error">>, <<"urn:xmpp:jingle:1">>}, {<<"media-error">>, <<"urn:xmpp:jingle:1">>}, {<<"incompatible-parameters">>, <<"urn:xmpp:jingle:1">>}, {<<"gone">>, <<"urn:xmpp:jingle:1">>}, {<<"general-error">>, <<"urn:xmpp:jingle:1">>}, {<<"failed-transport">>, <<"urn:xmpp:jingle:1">>}, {<<"failed-application">>, <<"urn:xmpp:jingle:1">>}, {<<"expired">>, <<"urn:xmpp:jingle:1">>}, {<<"decline">>, <<"urn:xmpp:jingle:1">>}, {<<"connectivity-error">>, <<"urn:xmpp:jingle:1">>}, {<<"cancel">>, <<"urn:xmpp:jingle:1">>}, {<<"busy">>, <<"urn:xmpp:jingle:1">>}, {<<"alternative-session">>, <<"urn:xmpp:jingle:1">>}, {<<"security-required">>, <<"urn:xmpp:jingle:errors:1">>}, {<<"unsupported-info">>, <<"urn:xmpp:jingle:errors:1">>}, {<<"unknown-session">>, <<"urn:xmpp:jingle:errors:1">>}, {<<"tie-break">>, <<"urn:xmpp:jingle:errors:1">>}, {<<"out-of-order">>, <<"urn:xmpp:jingle:errors:1">>}]. do_encode({jingle_error, 'out-of-order'} = Out_of_order, TopXMLNS) -> encode_jingle_error_out_of_order(Out_of_order, TopXMLNS); do_encode({jingle_error, 'tie-break'} = Tie_break, TopXMLNS) -> encode_jingle_error_tie_break(Tie_break, TopXMLNS); do_encode({jingle_error, 'unknown-session'} = Unknown_session, TopXMLNS) -> encode_jingle_error_unknown_session(Unknown_session, TopXMLNS); do_encode({jingle_error, 'unsupported-info'} = Unsupported_info, TopXMLNS) -> encode_jingle_error_unsupported_info(Unsupported_info, TopXMLNS); do_encode({jingle_error, 'security-required'} = Security_required, TopXMLNS) -> encode_jingle_error_security_required(Security_required, TopXMLNS); do_encode({text, _, _} = Text, TopXMLNS) -> encode_jingle_reason_text(Text, TopXMLNS); do_encode({jingle_reason, _, _, _} = Reason, TopXMLNS) -> encode_jingle_reason(Reason, TopXMLNS); do_encode({jingle_content, _, _, _, _, _} = Content, TopXMLNS) -> encode_jingle_content(Content, TopXMLNS); do_encode({jingle, _, _, _, _, _, _, _} = Jingle, TopXMLNS) -> encode_jingle(Jingle, TopXMLNS). do_get_name({jingle, _, _, _, _, _, _, _}) -> <<"jingle">>; do_get_name({jingle_content, _, _, _, _, _}) -> <<"content">>; do_get_name({jingle_error, 'out-of-order'}) -> <<"out-of-order">>; do_get_name({jingle_error, 'security-required'}) -> <<"security-required">>; do_get_name({jingle_error, 'tie-break'}) -> <<"tie-break">>; do_get_name({jingle_error, 'unknown-session'}) -> <<"unknown-session">>; do_get_name({jingle_error, 'unsupported-info'}) -> <<"unsupported-info">>; do_get_name({jingle_reason, _, _, _}) -> <<"reason">>; do_get_name({text, _, _}) -> <<"text">>. do_get_ns({jingle, _, _, _, _, _, _, _}) -> <<"urn:xmpp:jingle:1">>; do_get_ns({jingle_content, _, _, _, _, _}) -> <<"urn:xmpp:jingle:1">>; do_get_ns({jingle_error, 'out-of-order'}) -> <<"urn:xmpp:jingle:errors:1">>; do_get_ns({jingle_error, 'security-required'}) -> <<"urn:xmpp:jingle:errors:1">>; do_get_ns({jingle_error, 'tie-break'}) -> <<"urn:xmpp:jingle:errors:1">>; do_get_ns({jingle_error, 'unknown-session'}) -> <<"urn:xmpp:jingle:errors:1">>; do_get_ns({jingle_error, 'unsupported-info'}) -> <<"urn:xmpp:jingle:errors:1">>; do_get_ns({jingle_reason, _, _, _}) -> <<"urn:xmpp:jingle:1">>; do_get_ns({text, _, _}) -> <<"urn:xmpp:jingle:1">>. get_els({jingle_reason, _reason, _text, _sub_els}) -> _sub_els; get_els({jingle_content, _creator, _disposition, _name, _senders, _sub_els}) -> _sub_els; get_els({jingle, _action, _sid, _initiator, _responder, _content, _reason, _sub_els}) -> _sub_els. set_els({jingle_reason, _reason, _text, _}, _sub_els) -> {jingle_reason, _reason, _text, _sub_els}; set_els({jingle_content, _creator, _disposition, _name, _senders, _}, _sub_els) -> {jingle_content, _creator, _disposition, _name, _senders, _sub_els}; set_els({jingle, _action, _sid, _initiator, _responder, _content, _reason, _}, _sub_els) -> {jingle, _action, _sid, _initiator, _responder, _content, _reason, _sub_els}. pp(jingle_error, 1) -> [reason]; pp(text, 2) -> [lang, data]; pp(jingle_reason, 3) -> [reason, text, sub_els]; pp(jingle_content, 5) -> [creator, disposition, name, senders, sub_els]; pp(jingle, 7) -> [action, sid, initiator, responder, content, reason, sub_els]; pp(_, _) -> no. records() -> [{jingle_error, 1}, {text, 2}, {jingle_reason, 3}, {jingle_content, 5}, {jingle, 7}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). decode_jingle(__TopXMLNS, __Opts, {xmlel, <<"jingle">>, _attrs, _els}) -> {Content, Reason, __Els} = decode_jingle_els(__TopXMLNS, __Opts, _els, [], undefined, []), {Action, Sid, Initiator, Responder} = decode_jingle_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {jingle, Action, Sid, Initiator, Responder, Content, Reason, __Els}. decode_jingle_els(__TopXMLNS, __Opts, [], Content, Reason, __Els) -> {lists:reverse(Content), Reason, lists:reverse(__Els)}; decode_jingle_els(__TopXMLNS, __Opts, [{xmlel, <<"content">>, _attrs, _} = _el | _els], Content, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_els(__TopXMLNS, __Opts, _els, [decode_jingle_content(<<"urn:xmpp:jingle:1">>, __Opts, _el) | Content], Reason, __Els); _ -> decode_jingle_els(__TopXMLNS, __Opts, _els, Content, Reason, [_el | __Els]) end; decode_jingle_els(__TopXMLNS, __Opts, [{xmlel, <<"reason">>, _attrs, _} = _el | _els], Content, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_els(__TopXMLNS, __Opts, _els, Content, decode_jingle_reason(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_els(__TopXMLNS, __Opts, _els, Content, Reason, [_el | __Els]) end; decode_jingle_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Content, Reason, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_jingle_els(__TopXMLNS, __Opts, _els, Content, Reason, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_jingle_els(__TopXMLNS, __Opts, _els, Content, Reason, [_el | __Els]); Mod -> decode_jingle_els(__TopXMLNS, __Opts, _els, Content, Reason, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_jingle_els(__TopXMLNS, __Opts, [_ | _els], Content, Reason, __Els) -> decode_jingle_els(__TopXMLNS, __Opts, _els, Content, Reason, __Els). decode_jingle_attrs(__TopXMLNS, [{<<"action">>, _val} | _attrs], _Action, Sid, Initiator, Responder) -> decode_jingle_attrs(__TopXMLNS, _attrs, _val, Sid, Initiator, Responder); decode_jingle_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], Action, _Sid, Initiator, Responder) -> decode_jingle_attrs(__TopXMLNS, _attrs, Action, _val, Initiator, Responder); decode_jingle_attrs(__TopXMLNS, [{<<"initiator">>, _val} | _attrs], Action, Sid, _Initiator, Responder) -> decode_jingle_attrs(__TopXMLNS, _attrs, Action, Sid, _val, Responder); decode_jingle_attrs(__TopXMLNS, [{<<"responder">>, _val} | _attrs], Action, Sid, Initiator, _Responder) -> decode_jingle_attrs(__TopXMLNS, _attrs, Action, Sid, Initiator, _val); decode_jingle_attrs(__TopXMLNS, [_ | _attrs], Action, Sid, Initiator, Responder) -> decode_jingle_attrs(__TopXMLNS, _attrs, Action, Sid, Initiator, Responder); decode_jingle_attrs(__TopXMLNS, [], Action, Sid, Initiator, Responder) -> {decode_jingle_attr_action(__TopXMLNS, Action), decode_jingle_attr_sid(__TopXMLNS, Sid), decode_jingle_attr_initiator(__TopXMLNS, Initiator), decode_jingle_attr_responder(__TopXMLNS, Responder)}. encode_jingle({jingle, Action, Sid, Initiator, Responder, Content, Reason, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_jingle_$content'(Content, __NewTopXMLNS, 'encode_jingle_$reason'(Reason, __NewTopXMLNS, []))), _attrs = encode_jingle_attr_responder(Responder, encode_jingle_attr_initiator(Initiator, encode_jingle_attr_sid(Sid, encode_jingle_attr_action(Action, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"jingle">>, _attrs, _els}. 'encode_jingle_$content'([], __TopXMLNS, _acc) -> _acc; 'encode_jingle_$content'([Content | _els], __TopXMLNS, _acc) -> 'encode_jingle_$content'(_els, __TopXMLNS, [encode_jingle_content(Content, __TopXMLNS) | _acc]). 'encode_jingle_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_$reason'(Reason, __TopXMLNS, _acc) -> [encode_jingle_reason(Reason, __TopXMLNS) | _acc]. decode_jingle_attr_action(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"action">>, <<"jingle">>, __TopXMLNS}}); decode_jingle_attr_action(__TopXMLNS, _val) -> case catch dec_enum(_val, ['content-accept', 'content-add', 'content-modify', 'content-reject', 'content-remove', 'description-info', 'security-info', 'session-accept', 'session-info', 'session-initiate', 'session-terminate', 'transport-accept', 'transport-info', 'transport-reject', 'transport-replace']) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"action">>, <<"jingle">>, __TopXMLNS}}); _res -> _res end. encode_jingle_attr_action(_val, _acc) -> [{<<"action">>, enc_enum(_val)} | _acc]. decode_jingle_attr_sid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"sid">>, <<"jingle">>, __TopXMLNS}}); decode_jingle_attr_sid(__TopXMLNS, _val) -> _val. encode_jingle_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. decode_jingle_attr_initiator(__TopXMLNS, undefined) -> undefined; decode_jingle_attr_initiator(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"initiator">>, <<"jingle">>, __TopXMLNS}}); _res -> _res end. encode_jingle_attr_initiator(undefined, _acc) -> _acc; encode_jingle_attr_initiator(_val, _acc) -> [{<<"initiator">>, jid:encode(_val)} | _acc]. decode_jingle_attr_responder(__TopXMLNS, undefined) -> undefined; decode_jingle_attr_responder(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"responder">>, <<"jingle">>, __TopXMLNS}}); _res -> _res end. encode_jingle_attr_responder(undefined, _acc) -> _acc; encode_jingle_attr_responder(_val, _acc) -> [{<<"responder">>, jid:encode(_val)} | _acc]. decode_jingle_content(__TopXMLNS, __Opts, {xmlel, <<"content">>, _attrs, _els}) -> __Els = decode_jingle_content_els(__TopXMLNS, __Opts, _els, []), {Creator, Disposition, Name, Senders} = decode_jingle_content_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {jingle_content, Creator, Disposition, Name, Senders, __Els}. decode_jingle_content_els(__TopXMLNS, __Opts, [], __Els) -> lists:reverse(__Els); decode_jingle_content_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_jingle_content_els(__TopXMLNS, __Opts, _els, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_jingle_content_els(__TopXMLNS, __Opts, _els, [_el | __Els]); Mod -> decode_jingle_content_els(__TopXMLNS, __Opts, _els, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_jingle_content_els(__TopXMLNS, __Opts, [_ | _els], __Els) -> decode_jingle_content_els(__TopXMLNS, __Opts, _els, __Els). decode_jingle_content_attrs(__TopXMLNS, [{<<"creator">>, _val} | _attrs], _Creator, Disposition, Name, Senders) -> decode_jingle_content_attrs(__TopXMLNS, _attrs, _val, Disposition, Name, Senders); decode_jingle_content_attrs(__TopXMLNS, [{<<"disposition">>, _val} | _attrs], Creator, _Disposition, Name, Senders) -> decode_jingle_content_attrs(__TopXMLNS, _attrs, Creator, _val, Name, Senders); decode_jingle_content_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], Creator, Disposition, _Name, Senders) -> decode_jingle_content_attrs(__TopXMLNS, _attrs, Creator, Disposition, _val, Senders); decode_jingle_content_attrs(__TopXMLNS, [{<<"senders">>, _val} | _attrs], Creator, Disposition, Name, _Senders) -> decode_jingle_content_attrs(__TopXMLNS, _attrs, Creator, Disposition, Name, _val); decode_jingle_content_attrs(__TopXMLNS, [_ | _attrs], Creator, Disposition, Name, Senders) -> decode_jingle_content_attrs(__TopXMLNS, _attrs, Creator, Disposition, Name, Senders); decode_jingle_content_attrs(__TopXMLNS, [], Creator, Disposition, Name, Senders) -> {decode_jingle_content_attr_creator(__TopXMLNS, Creator), decode_jingle_content_attr_disposition(__TopXMLNS, Disposition), decode_jingle_content_attr_name(__TopXMLNS, Name), decode_jingle_content_attr_senders(__TopXMLNS, Senders)}. encode_jingle_content({jingle_content, Creator, Disposition, Name, Senders, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els], _attrs = encode_jingle_content_attr_senders(Senders, encode_jingle_content_attr_name(Name, encode_jingle_content_attr_disposition(Disposition, encode_jingle_content_attr_creator(Creator, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"content">>, _attrs, _els}. decode_jingle_content_attr_creator(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"creator">>, <<"content">>, __TopXMLNS}}); decode_jingle_content_attr_creator(__TopXMLNS, _val) -> case catch dec_enum(_val, [initiator, responder]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"creator">>, <<"content">>, __TopXMLNS}}); _res -> _res end. encode_jingle_content_attr_creator(_val, _acc) -> [{<<"creator">>, enc_enum(_val)} | _acc]. decode_jingle_content_attr_disposition(__TopXMLNS, undefined) -> <<>>; decode_jingle_content_attr_disposition(__TopXMLNS, _val) -> _val. encode_jingle_content_attr_disposition(<<>>, _acc) -> _acc; encode_jingle_content_attr_disposition(_val, _acc) -> [{<<"disposition">>, _val} | _acc]. decode_jingle_content_attr_name(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"name">>, <<"content">>, __TopXMLNS}}); decode_jingle_content_attr_name(__TopXMLNS, _val) -> _val. encode_jingle_content_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_jingle_content_attr_senders(__TopXMLNS, undefined) -> both; decode_jingle_content_attr_senders(__TopXMLNS, _val) -> case catch dec_enum(_val, [both, initiator, none, responder]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"senders">>, <<"content">>, __TopXMLNS}}); _res -> _res end. encode_jingle_content_attr_senders(both, _acc) -> _acc; encode_jingle_content_attr_senders(_val, _acc) -> [{<<"senders">>, enc_enum(_val)} | _acc]. decode_jingle_reason(__TopXMLNS, __Opts, {xmlel, <<"reason">>, _attrs, _els}) -> {Text, Reason, __Els} = decode_jingle_reason_els(__TopXMLNS, __Opts, _els, [], undefined, []), {jingle_reason, Reason, Text, __Els}. decode_jingle_reason_els(__TopXMLNS, __Opts, [], Text, Reason, __Els) -> {lists:reverse(Text), Reason, lists:reverse(__Els)}; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"text">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, [decode_jingle_reason_text(<<"urn:xmpp:jingle:1">>, __Opts, _el) | Text], Reason, __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"alternative-session">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_alternative_session(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"busy">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_busy(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"cancel">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_cancel(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"connectivity-error">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_connectivity_error(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"decline">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_decline(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"expired">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_expired(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"failed-application">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_failed_application(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"failed-transport">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_failed_transport(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"general-error">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_general_error(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"gone">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_gone(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"incompatible-parameters">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_incompatible_parameters(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"media-error">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_media_error(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"security-error">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_security_error(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"success">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_success(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"timeout">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_timeout(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"unsupported-applications">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_unsupported_applications(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, <<"unsupported-transports">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:1">> -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, decode_jingle_reason_unsupported_transports(<<"urn:xmpp:jingle:1">>, __Opts, _el), __Els); _ -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_jingle_reason_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Text, Reason, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]); Mod -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_jingle_reason_els(__TopXMLNS, __Opts, [_ | _els], Text, Reason, __Els) -> decode_jingle_reason_els(__TopXMLNS, __Opts, _els, Text, Reason, __Els). encode_jingle_reason({jingle_reason, Reason, Text, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_jingle_reason_$text'(Text, __NewTopXMLNS, 'encode_jingle_reason_$reason'(Reason, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"reason">>, _attrs, _els}. 'encode_jingle_reason_$text'([], __TopXMLNS, _acc) -> _acc; 'encode_jingle_reason_$text'([Text | _els], __TopXMLNS, _acc) -> 'encode_jingle_reason_$text'(_els, __TopXMLNS, [encode_jingle_reason_text(Text, __TopXMLNS) | _acc]). 'encode_jingle_reason_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_reason_$reason'('alternative-session' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_alternative_session(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'(busy = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_busy(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'(cancel = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_cancel(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('connectivity-error' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_connectivity_error(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'(decline = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_decline(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'(expired = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_expired(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('failed-application' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_failed_application(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('failed-transport' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_failed_transport(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('general-error' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_general_error(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'(gone = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_gone(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('incompatible-parameters' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_incompatible_parameters(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('media-error' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_media_error(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('security-error' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_security_error(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'(success = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_success(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'(timeout = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_timeout(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('unsupported-applications' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_unsupported_applications(Reason, __TopXMLNS) | _acc]; 'encode_jingle_reason_$reason'('unsupported-transports' = Reason, __TopXMLNS, _acc) -> [encode_jingle_reason_unsupported_transports(Reason, __TopXMLNS) | _acc]. decode_jingle_reason_text(__TopXMLNS, __Opts, {xmlel, <<"text">>, _attrs, _els}) -> Data = decode_jingle_reason_text_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_jingle_reason_text_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_jingle_reason_text_els(__TopXMLNS, __Opts, [], Data) -> decode_jingle_reason_text_cdata(__TopXMLNS, Data); decode_jingle_reason_text_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_jingle_reason_text_els(__TopXMLNS, __Opts, _els, <>); decode_jingle_reason_text_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_jingle_reason_text_els(__TopXMLNS, __Opts, _els, Data). decode_jingle_reason_text_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_jingle_reason_text_attrs(__TopXMLNS, _attrs, _val); decode_jingle_reason_text_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_jingle_reason_text_attrs(__TopXMLNS, _attrs, Lang); decode_jingle_reason_text_attrs(__TopXMLNS, [], Lang) -> 'decode_jingle_reason_text_attr_xml:lang'(__TopXMLNS, Lang). encode_jingle_reason_text({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = encode_jingle_reason_text_cdata(Data, []), _attrs = 'encode_jingle_reason_text_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"text">>, _attrs, _els}. 'decode_jingle_reason_text_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_jingle_reason_text_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"text">>, __TopXMLNS}}); _res -> _res end. 'encode_jingle_reason_text_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_jingle_reason_text_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_jingle_reason_text_cdata(__TopXMLNS, <<>>) -> <<>>; decode_jingle_reason_text_cdata(__TopXMLNS, _val) -> _val. encode_jingle_reason_text_cdata(<<>>, _acc) -> _acc; encode_jingle_reason_text_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_jingle_reason_unsupported_transports(__TopXMLNS, __Opts, {xmlel, <<"unsupported-transports">>, _attrs, _els}) -> 'unsupported-transports'. encode_jingle_reason_unsupported_transports('unsupported-transports', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-transports">>, _attrs, _els}. decode_jingle_reason_unsupported_applications(__TopXMLNS, __Opts, {xmlel, <<"unsupported-applications">>, _attrs, _els}) -> 'unsupported-applications'. encode_jingle_reason_unsupported_applications('unsupported-applications', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-applications">>, _attrs, _els}. decode_jingle_reason_timeout(__TopXMLNS, __Opts, {xmlel, <<"timeout">>, _attrs, _els}) -> timeout. encode_jingle_reason_timeout(timeout, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"timeout">>, _attrs, _els}. decode_jingle_reason_success(__TopXMLNS, __Opts, {xmlel, <<"success">>, _attrs, _els}) -> success. encode_jingle_reason_success(success, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"success">>, _attrs, _els}. decode_jingle_reason_security_error(__TopXMLNS, __Opts, {xmlel, <<"security-error">>, _attrs, _els}) -> 'security-error'. encode_jingle_reason_security_error('security-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"security-error">>, _attrs, _els}. decode_jingle_reason_media_error(__TopXMLNS, __Opts, {xmlel, <<"media-error">>, _attrs, _els}) -> 'media-error'. encode_jingle_reason_media_error('media-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"media-error">>, _attrs, _els}. decode_jingle_reason_incompatible_parameters(__TopXMLNS, __Opts, {xmlel, <<"incompatible-parameters">>, _attrs, _els}) -> 'incompatible-parameters'. encode_jingle_reason_incompatible_parameters('incompatible-parameters', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"incompatible-parameters">>, _attrs, _els}. decode_jingle_reason_gone(__TopXMLNS, __Opts, {xmlel, <<"gone">>, _attrs, _els}) -> gone. encode_jingle_reason_gone(gone, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"gone">>, _attrs, _els}. decode_jingle_reason_general_error(__TopXMLNS, __Opts, {xmlel, <<"general-error">>, _attrs, _els}) -> 'general-error'. encode_jingle_reason_general_error('general-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"general-error">>, _attrs, _els}. decode_jingle_reason_failed_transport(__TopXMLNS, __Opts, {xmlel, <<"failed-transport">>, _attrs, _els}) -> 'failed-transport'. encode_jingle_reason_failed_transport('failed-transport', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"failed-transport">>, _attrs, _els}. decode_jingle_reason_failed_application(__TopXMLNS, __Opts, {xmlel, <<"failed-application">>, _attrs, _els}) -> 'failed-application'. encode_jingle_reason_failed_application('failed-application', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"failed-application">>, _attrs, _els}. decode_jingle_reason_expired(__TopXMLNS, __Opts, {xmlel, <<"expired">>, _attrs, _els}) -> expired. encode_jingle_reason_expired(expired, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"expired">>, _attrs, _els}. decode_jingle_reason_decline(__TopXMLNS, __Opts, {xmlel, <<"decline">>, _attrs, _els}) -> decline. encode_jingle_reason_decline(decline, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"decline">>, _attrs, _els}. decode_jingle_reason_connectivity_error(__TopXMLNS, __Opts, {xmlel, <<"connectivity-error">>, _attrs, _els}) -> 'connectivity-error'. encode_jingle_reason_connectivity_error('connectivity-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"connectivity-error">>, _attrs, _els}. decode_jingle_reason_cancel(__TopXMLNS, __Opts, {xmlel, <<"cancel">>, _attrs, _els}) -> cancel. encode_jingle_reason_cancel(cancel, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"cancel">>, _attrs, _els}. decode_jingle_reason_busy(__TopXMLNS, __Opts, {xmlel, <<"busy">>, _attrs, _els}) -> busy. encode_jingle_reason_busy(busy, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"busy">>, _attrs, _els}. decode_jingle_reason_alternative_session(__TopXMLNS, __Opts, {xmlel, <<"alternative-session">>, _attrs, _els}) -> 'alternative-session'. encode_jingle_reason_alternative_session('alternative-session', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"alternative-session">>, _attrs, _els}. decode_jingle_error_security_required(__TopXMLNS, __Opts, {xmlel, <<"security-required">>, _attrs, _els}) -> {jingle_error, 'security-required'}. encode_jingle_error_security_required({jingle_error, 'security-required'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:errors:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"security-required">>, _attrs, _els}. decode_jingle_error_unsupported_info(__TopXMLNS, __Opts, {xmlel, <<"unsupported-info">>, _attrs, _els}) -> {jingle_error, 'unsupported-info'}. encode_jingle_error_unsupported_info({jingle_error, 'unsupported-info'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:errors:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-info">>, _attrs, _els}. decode_jingle_error_unknown_session(__TopXMLNS, __Opts, {xmlel, <<"unknown-session">>, _attrs, _els}) -> {jingle_error, 'unknown-session'}. encode_jingle_error_unknown_session({jingle_error, 'unknown-session'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:errors:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unknown-session">>, _attrs, _els}. decode_jingle_error_tie_break(__TopXMLNS, __Opts, {xmlel, <<"tie-break">>, _attrs, _els}) -> {jingle_error, 'tie-break'}. encode_jingle_error_tie_break({jingle_error, 'tie-break'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:errors:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"tie-break">>, _attrs, _els}. decode_jingle_error_out_of_order(__TopXMLNS, __Opts, {xmlel, <<"out-of-order">>, _attrs, _els}) -> {jingle_error, 'out-of-order'}. encode_jingle_error_out_of_order({jingle_error, 'out-of-order'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:errors:1">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"out-of-order">>, _attrs, _els}. xmpp-1.4.4/src/xep0030.erl0000644000232200023220000004213613610066730015454 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0030). -compile(export_all). do_decode(<<"query">>, <<"http://jabber.org/protocol/disco#items">>, El, Opts) -> decode_disco_items(<<"http://jabber.org/protocol/disco#items">>, Opts, El); do_decode(<<"item">>, <<"http://jabber.org/protocol/disco#items">>, El, Opts) -> decode_disco_item(<<"http://jabber.org/protocol/disco#items">>, Opts, El); do_decode(<<"query">>, <<"http://jabber.org/protocol/disco#info">>, El, Opts) -> decode_disco_info(<<"http://jabber.org/protocol/disco#info">>, Opts, El); do_decode(<<"feature">>, <<"http://jabber.org/protocol/disco#info">>, El, Opts) -> decode_disco_feature(<<"http://jabber.org/protocol/disco#info">>, Opts, El); do_decode(<<"identity">>, <<"http://jabber.org/protocol/disco#info">>, El, Opts) -> decode_disco_identity(<<"http://jabber.org/protocol/disco#info">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"http://jabber.org/protocol/disco#items">>}, {<<"item">>, <<"http://jabber.org/protocol/disco#items">>}, {<<"query">>, <<"http://jabber.org/protocol/disco#info">>}, {<<"feature">>, <<"http://jabber.org/protocol/disco#info">>}, {<<"identity">>, <<"http://jabber.org/protocol/disco#info">>}]. do_encode({identity, _, _, _, _} = Identity, TopXMLNS) -> encode_disco_identity(Identity, TopXMLNS); do_encode({disco_info, _, _, _, _} = Query, TopXMLNS) -> encode_disco_info(Query, TopXMLNS); do_encode({disco_item, _, _, _} = Item, TopXMLNS) -> encode_disco_item(Item, TopXMLNS); do_encode({disco_items, _, _, _} = Query, TopXMLNS) -> encode_disco_items(Query, TopXMLNS). do_get_name({disco_info, _, _, _, _}) -> <<"query">>; do_get_name({disco_item, _, _, _}) -> <<"item">>; do_get_name({disco_items, _, _, _}) -> <<"query">>; do_get_name({identity, _, _, _, _}) -> <<"identity">>. do_get_ns({disco_info, _, _, _, _}) -> <<"http://jabber.org/protocol/disco#info">>; do_get_ns({disco_item, _, _, _}) -> <<"http://jabber.org/protocol/disco#items">>; do_get_ns({disco_items, _, _, _}) -> <<"http://jabber.org/protocol/disco#items">>; do_get_ns({identity, _, _, _, _}) -> <<"http://jabber.org/protocol/disco#info">>. pp(identity, 4) -> [category, type, lang, name]; pp(disco_info, 4) -> [node, identities, features, xdata]; pp(disco_item, 3) -> [jid, name, node]; pp(disco_items, 3) -> [node, items, rsm]; pp(_, _) -> no. records() -> [{identity, 4}, {disco_info, 4}, {disco_item, 3}, {disco_items, 3}]. decode_disco_items(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Items, Rsm} = decode_disco_items_els(__TopXMLNS, __Opts, _els, [], undefined), Node = decode_disco_items_attrs(__TopXMLNS, _attrs, undefined), {disco_items, Node, Items, Rsm}. decode_disco_items_els(__TopXMLNS, __Opts, [], Items, Rsm) -> {lists:reverse(Items), Rsm}; decode_disco_items_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/disco#items">> -> decode_disco_items_els(__TopXMLNS, __Opts, _els, [decode_disco_item(<<"http://jabber.org/protocol/disco#items">>, __Opts, _el) | Items], Rsm); _ -> decode_disco_items_els(__TopXMLNS, __Opts, _els, Items, Rsm) end; decode_disco_items_els(__TopXMLNS, __Opts, [{xmlel, <<"set">>, _attrs, _} = _el | _els], Items, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_disco_items_els(__TopXMLNS, __Opts, _els, Items, xep0059:decode_rsm_set(<<"http://jabber.org/protocol/rsm">>, __Opts, _el)); _ -> decode_disco_items_els(__TopXMLNS, __Opts, _els, Items, Rsm) end; decode_disco_items_els(__TopXMLNS, __Opts, [_ | _els], Items, Rsm) -> decode_disco_items_els(__TopXMLNS, __Opts, _els, Items, Rsm). decode_disco_items_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_disco_items_attrs(__TopXMLNS, _attrs, _val); decode_disco_items_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_disco_items_attrs(__TopXMLNS, _attrs, Node); decode_disco_items_attrs(__TopXMLNS, [], Node) -> decode_disco_items_attr_node(__TopXMLNS, Node). encode_disco_items({disco_items, Node, Items, Rsm}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/disco#items">>, [], __TopXMLNS), _els = lists:reverse('encode_disco_items_$items'(Items, __NewTopXMLNS, 'encode_disco_items_$rsm'(Rsm, __NewTopXMLNS, []))), _attrs = encode_disco_items_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"query">>, _attrs, _els}. 'encode_disco_items_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_disco_items_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_disco_items_$items'(_els, __TopXMLNS, [encode_disco_item(Items, __TopXMLNS) | _acc]). 'encode_disco_items_$rsm'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_disco_items_$rsm'(Rsm, __TopXMLNS, _acc) -> [xep0059:encode_rsm_set(Rsm, __TopXMLNS) | _acc]. decode_disco_items_attr_node(__TopXMLNS, undefined) -> <<>>; decode_disco_items_attr_node(__TopXMLNS, _val) -> _val. encode_disco_items_attr_node(<<>>, _acc) -> _acc; encode_disco_items_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_disco_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> {Jid, Name, Node} = decode_disco_item_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {disco_item, Jid, Name, Node}. decode_disco_item_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Name, Node) -> decode_disco_item_attrs(__TopXMLNS, _attrs, _val, Name, Node); decode_disco_item_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], Jid, _Name, Node) -> decode_disco_item_attrs(__TopXMLNS, _attrs, Jid, _val, Node); decode_disco_item_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Jid, Name, _Node) -> decode_disco_item_attrs(__TopXMLNS, _attrs, Jid, Name, _val); decode_disco_item_attrs(__TopXMLNS, [_ | _attrs], Jid, Name, Node) -> decode_disco_item_attrs(__TopXMLNS, _attrs, Jid, Name, Node); decode_disco_item_attrs(__TopXMLNS, [], Jid, Name, Node) -> {decode_disco_item_attr_jid(__TopXMLNS, Jid), decode_disco_item_attr_name(__TopXMLNS, Name), decode_disco_item_attr_node(__TopXMLNS, Node)}. encode_disco_item({disco_item, Jid, Name, Node}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/disco#items">>, [], __TopXMLNS), _els = [], _attrs = encode_disco_item_attr_node(Node, encode_disco_item_attr_name(Name, encode_disco_item_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"item">>, _attrs, _els}. decode_disco_item_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"item">>, __TopXMLNS}}); decode_disco_item_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_disco_item_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_disco_item_attr_name(__TopXMLNS, undefined) -> <<>>; decode_disco_item_attr_name(__TopXMLNS, _val) -> _val. encode_disco_item_attr_name(<<>>, _acc) -> _acc; encode_disco_item_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_disco_item_attr_node(__TopXMLNS, undefined) -> <<>>; decode_disco_item_attr_node(__TopXMLNS, _val) -> _val. encode_disco_item_attr_node(<<>>, _acc) -> _acc; encode_disco_item_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_disco_info(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Xdata, Features, Identities} = decode_disco_info_els(__TopXMLNS, __Opts, _els, [], [], []), Node = decode_disco_info_attrs(__TopXMLNS, _attrs, undefined), {disco_info, Node, Identities, Features, Xdata}. decode_disco_info_els(__TopXMLNS, __Opts, [], Xdata, Features, Identities) -> {lists:reverse(Xdata), lists:reverse(Features), lists:reverse(Identities)}; decode_disco_info_els(__TopXMLNS, __Opts, [{xmlel, <<"identity">>, _attrs, _} = _el | _els], Xdata, Features, Identities) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/disco#info">> -> decode_disco_info_els(__TopXMLNS, __Opts, _els, Xdata, Features, [decode_disco_identity(<<"http://jabber.org/protocol/disco#info">>, __Opts, _el) | Identities]); _ -> decode_disco_info_els(__TopXMLNS, __Opts, _els, Xdata, Features, Identities) end; decode_disco_info_els(__TopXMLNS, __Opts, [{xmlel, <<"feature">>, _attrs, _} = _el | _els], Xdata, Features, Identities) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/disco#info">> -> decode_disco_info_els(__TopXMLNS, __Opts, _els, Xdata, [decode_disco_feature(<<"http://jabber.org/protocol/disco#info">>, __Opts, _el) | Features], Identities); _ -> decode_disco_info_els(__TopXMLNS, __Opts, _els, Xdata, Features, Identities) end; decode_disco_info_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata, Features, Identities) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_disco_info_els(__TopXMLNS, __Opts, _els, [xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el) | Xdata], Features, Identities); _ -> decode_disco_info_els(__TopXMLNS, __Opts, _els, Xdata, Features, Identities) end; decode_disco_info_els(__TopXMLNS, __Opts, [_ | _els], Xdata, Features, Identities) -> decode_disco_info_els(__TopXMLNS, __Opts, _els, Xdata, Features, Identities). decode_disco_info_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_disco_info_attrs(__TopXMLNS, _attrs, _val); decode_disco_info_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_disco_info_attrs(__TopXMLNS, _attrs, Node); decode_disco_info_attrs(__TopXMLNS, [], Node) -> decode_disco_info_attr_node(__TopXMLNS, Node). encode_disco_info({disco_info, Node, Identities, Features, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/disco#info">>, [], __TopXMLNS), _els = lists:reverse('encode_disco_info_$xdata'(Xdata, __NewTopXMLNS, 'encode_disco_info_$features'(Features, __NewTopXMLNS, 'encode_disco_info_$identities'(Identities, __NewTopXMLNS, [])))), _attrs = encode_disco_info_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"query">>, _attrs, _els}. 'encode_disco_info_$xdata'([], __TopXMLNS, _acc) -> _acc; 'encode_disco_info_$xdata'([Xdata | _els], __TopXMLNS, _acc) -> 'encode_disco_info_$xdata'(_els, __TopXMLNS, [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]). 'encode_disco_info_$features'([], __TopXMLNS, _acc) -> _acc; 'encode_disco_info_$features'([Features | _els], __TopXMLNS, _acc) -> 'encode_disco_info_$features'(_els, __TopXMLNS, [encode_disco_feature(Features, __TopXMLNS) | _acc]). 'encode_disco_info_$identities'([], __TopXMLNS, _acc) -> _acc; 'encode_disco_info_$identities'([Identities | _els], __TopXMLNS, _acc) -> 'encode_disco_info_$identities'(_els, __TopXMLNS, [encode_disco_identity(Identities, __TopXMLNS) | _acc]). decode_disco_info_attr_node(__TopXMLNS, undefined) -> <<>>; decode_disco_info_attr_node(__TopXMLNS, _val) -> _val. encode_disco_info_attr_node(<<>>, _acc) -> _acc; encode_disco_info_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_disco_feature(__TopXMLNS, __Opts, {xmlel, <<"feature">>, _attrs, _els}) -> Var = decode_disco_feature_attrs(__TopXMLNS, _attrs, undefined), Var. decode_disco_feature_attrs(__TopXMLNS, [{<<"var">>, _val} | _attrs], _Var) -> decode_disco_feature_attrs(__TopXMLNS, _attrs, _val); decode_disco_feature_attrs(__TopXMLNS, [_ | _attrs], Var) -> decode_disco_feature_attrs(__TopXMLNS, _attrs, Var); decode_disco_feature_attrs(__TopXMLNS, [], Var) -> decode_disco_feature_attr_var(__TopXMLNS, Var). encode_disco_feature(Var, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/disco#info">>, [], __TopXMLNS), _els = [], _attrs = encode_disco_feature_attr_var(Var, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"feature">>, _attrs, _els}. decode_disco_feature_attr_var(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"var">>, <<"feature">>, __TopXMLNS}}); decode_disco_feature_attr_var(__TopXMLNS, _val) -> _val. encode_disco_feature_attr_var(_val, _acc) -> [{<<"var">>, _val} | _acc]. decode_disco_identity(__TopXMLNS, __Opts, {xmlel, <<"identity">>, _attrs, _els}) -> {Category, Type, Lang, Name} = decode_disco_identity_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {identity, Category, Type, Lang, Name}. decode_disco_identity_attrs(__TopXMLNS, [{<<"category">>, _val} | _attrs], _Category, Type, Lang, Name) -> decode_disco_identity_attrs(__TopXMLNS, _attrs, _val, Type, Lang, Name); decode_disco_identity_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Category, _Type, Lang, Name) -> decode_disco_identity_attrs(__TopXMLNS, _attrs, Category, _val, Lang, Name); decode_disco_identity_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], Category, Type, _Lang, Name) -> decode_disco_identity_attrs(__TopXMLNS, _attrs, Category, Type, _val, Name); decode_disco_identity_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], Category, Type, Lang, _Name) -> decode_disco_identity_attrs(__TopXMLNS, _attrs, Category, Type, Lang, _val); decode_disco_identity_attrs(__TopXMLNS, [_ | _attrs], Category, Type, Lang, Name) -> decode_disco_identity_attrs(__TopXMLNS, _attrs, Category, Type, Lang, Name); decode_disco_identity_attrs(__TopXMLNS, [], Category, Type, Lang, Name) -> {decode_disco_identity_attr_category(__TopXMLNS, Category), decode_disco_identity_attr_type(__TopXMLNS, Type), 'decode_disco_identity_attr_xml:lang'(__TopXMLNS, Lang), decode_disco_identity_attr_name(__TopXMLNS, Name)}. encode_disco_identity({identity, Category, Type, Lang, Name}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/disco#info">>, [], __TopXMLNS), _els = [], _attrs = encode_disco_identity_attr_name(Name, 'encode_disco_identity_attr_xml:lang'(Lang, encode_disco_identity_attr_type(Type, encode_disco_identity_attr_category(Category, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"identity">>, _attrs, _els}. decode_disco_identity_attr_category(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"category">>, <<"identity">>, __TopXMLNS}}); decode_disco_identity_attr_category(__TopXMLNS, _val) -> _val. encode_disco_identity_attr_category(_val, _acc) -> [{<<"category">>, _val} | _acc]. decode_disco_identity_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"identity">>, __TopXMLNS}}); decode_disco_identity_attr_type(__TopXMLNS, _val) -> _val. encode_disco_identity_attr_type(_val, _acc) -> [{<<"type">>, _val} | _acc]. 'decode_disco_identity_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_disco_identity_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"identity">>, __TopXMLNS}}); _res -> _res end. 'encode_disco_identity_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_disco_identity_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_disco_identity_attr_name(__TopXMLNS, undefined) -> <<>>; decode_disco_identity_attr_name(__TopXMLNS, _val) -> _val. encode_disco_identity_attr_name(<<>>, _acc) -> _acc; encode_disco_identity_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. xmpp-1.4.4/src/xep0060.erl0000644000232200023220000045175313610066730015470 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0060). -compile(export_all). do_decode(<<"unsupported-access-model">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_unsupported_access_model(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"unsupported">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_unsupported(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"too-many-subscriptions">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_too_many_subscriptions(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"subid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_subid_required(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"presence-subscription-required">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_presence_subscription_required(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"precondition-not-met">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_precondition_not_met(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"pending-subscription">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_pending_subscription(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"payload-required">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_payload_required(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"payload-too-big">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_payload_too_big(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"not-subscribed">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_not_subscribed(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"not-in-roster-group">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_not_in_roster_group(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"nodeid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_nodeid_required(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"max-nodes-exceeded">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_max_nodes_exceeded(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"max-items-exceeded">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_max_items_exceeded(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"jid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_jid_required(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"item-required">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_item_required(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"item-forbidden">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_item_forbidden(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"invalid-subid">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_invalid_subid(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"invalid-payload">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_invalid_payload(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"invalid-options">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_invalid_options(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"invalid-jid">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_invalid_jid(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"configuration-required">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_configuration_required(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"closed-node">>, <<"http://jabber.org/protocol/pubsub#errors">>, El, Opts) -> decode_pubsub_error_closed_node(<<"http://jabber.org/protocol/pubsub#errors">>, Opts, El); do_decode(<<"pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_owner(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"pubsub">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"purge">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"purge">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"purge">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"delete">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"delete">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"delete">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"redirect">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_redirect(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"redirect">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_redirect(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"redirect">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_redirect(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"default">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_default(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"default">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_default(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"publish-options">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_publish_options(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"configure">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_configure(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"configure">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_configure(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"create">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_create(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"create">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_create(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"retract">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_retract(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"options">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_options(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"publish">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_publish(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"unsubscribe">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_unsubscribe(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"subscribe">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_subscribe(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"affiliations">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_owner_affiliations(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"affiliations">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_affiliations(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"subscriptions">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_subscriptions(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"subscriptions">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_subscriptions(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"event">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_event(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"items">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_items(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"items">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_items(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"item">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_item(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"item">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_item(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"retract">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_event_retract(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"configuration">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_event_configuration(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(<<"affiliation">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_owner_affiliation(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"affiliation">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_affiliation(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"subscription">>, <<"http://jabber.org/protocol/pubsub">>, El, Opts) -> decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub">>, Opts, El); do_decode(<<"subscription">>, <<"http://jabber.org/protocol/pubsub#owner">>, El, Opts) -> decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#owner">>, Opts, El); do_decode(<<"subscription">>, <<"http://jabber.org/protocol/pubsub#event">>, El, Opts) -> decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#event">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"unsupported-access-model">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"unsupported">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"too-many-subscriptions">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"subid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"presence-subscription-required">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"precondition-not-met">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"pending-subscription">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"payload-required">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"payload-too-big">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"not-subscribed">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"not-in-roster-group">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"nodeid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"max-nodes-exceeded">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"max-items-exceeded">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"jid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"item-required">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"item-forbidden">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"invalid-subid">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"invalid-payload">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"invalid-options">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"invalid-jid">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"configuration-required">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"closed-node">>, <<"http://jabber.org/protocol/pubsub#errors">>}, {<<"pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"pubsub">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"purge">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"purge">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"purge">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"delete">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"delete">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"delete">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"redirect">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"redirect">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"redirect">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"default">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"default">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"publish-options">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"configure">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"configure">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"create">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"create">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"retract">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"options">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"publish">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"unsubscribe">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"subscribe">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"affiliations">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"affiliations">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"subscriptions">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"subscriptions">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"event">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"items">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"items">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"item">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"item">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"retract">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"configuration">>, <<"http://jabber.org/protocol/pubsub#event">>}, {<<"affiliation">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"affiliation">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"subscription">>, <<"http://jabber.org/protocol/pubsub">>}, {<<"subscription">>, <<"http://jabber.org/protocol/pubsub#owner">>}, {<<"subscription">>, <<"http://jabber.org/protocol/pubsub#event">>}]. do_encode({ps_subscription, _, _, _, _, _, _} = Subscription, TopXMLNS) -> encode_pubsub_subscription(Subscription, TopXMLNS); do_encode({ps_affiliation, <<"http://jabber.org/protocol/pubsub">>, _, _, _} = Affiliation, TopXMLNS) -> encode_pubsub_affiliation(Affiliation, TopXMLNS); do_encode({ps_affiliation, <<>>, _, _, _} = Affiliation, TopXMLNS = <<"http://jabber.org/protocol/pubsub">>) -> encode_pubsub_affiliation(Affiliation, TopXMLNS); do_encode({ps_affiliation, <<"http://jabber.org/protocol/pubsub#owner">>, _, _, _} = Affiliation, TopXMLNS) -> encode_pubsub_owner_affiliation(Affiliation, TopXMLNS); do_encode({ps_affiliation, <<>>, _, _, _} = Affiliation, TopXMLNS = <<"http://jabber.org/protocol/pubsub#owner">>) -> encode_pubsub_owner_affiliation(Affiliation, TopXMLNS); do_encode({ps_item, _, _, _, _, _} = Item, TopXMLNS) -> encode_pubsub_item(Item, TopXMLNS); do_encode({ps_items, _, _, _, _, _, _} = Items, TopXMLNS) -> encode_pubsub_items(Items, TopXMLNS); do_encode({ps_event, _, _, _, _, _, _} = Event, TopXMLNS) -> encode_pubsub_event(Event, TopXMLNS); do_encode({ps_subscribe, _, _} = Subscribe, TopXMLNS) -> encode_pubsub_subscribe(Subscribe, TopXMLNS); do_encode({ps_unsubscribe, _, _, _} = Unsubscribe, TopXMLNS) -> encode_pubsub_unsubscribe(Unsubscribe, TopXMLNS); do_encode({ps_publish, _, _} = Publish, TopXMLNS) -> encode_pubsub_publish(Publish, TopXMLNS); do_encode({ps_options, _, _, _, _} = Options, TopXMLNS) -> encode_pubsub_options(Options, TopXMLNS); do_encode({ps_retract, _, _, _} = Retract, TopXMLNS) -> encode_pubsub_retract(Retract, TopXMLNS); do_encode({pubsub, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} = Pubsub, TopXMLNS) -> encode_pubsub(Pubsub, TopXMLNS); do_encode({pubsub_owner, _, _, _, _, _, _} = Pubsub, TopXMLNS) -> encode_pubsub_owner(Pubsub, TopXMLNS); do_encode({ps_error, 'closed-node', _} = Closed_node, TopXMLNS) -> encode_pubsub_error_closed_node(Closed_node, TopXMLNS); do_encode({ps_error, 'configuration-required', _} = Configuration_required, TopXMLNS) -> encode_pubsub_error_configuration_required(Configuration_required, TopXMLNS); do_encode({ps_error, 'invalid-jid', _} = Invalid_jid, TopXMLNS) -> encode_pubsub_error_invalid_jid(Invalid_jid, TopXMLNS); do_encode({ps_error, 'invalid-options', _} = Invalid_options, TopXMLNS) -> encode_pubsub_error_invalid_options(Invalid_options, TopXMLNS); do_encode({ps_error, 'invalid-payload', _} = Invalid_payload, TopXMLNS) -> encode_pubsub_error_invalid_payload(Invalid_payload, TopXMLNS); do_encode({ps_error, 'invalid-subid', _} = Invalid_subid, TopXMLNS) -> encode_pubsub_error_invalid_subid(Invalid_subid, TopXMLNS); do_encode({ps_error, 'item-forbidden', _} = Item_forbidden, TopXMLNS) -> encode_pubsub_error_item_forbidden(Item_forbidden, TopXMLNS); do_encode({ps_error, 'item-required', _} = Item_required, TopXMLNS) -> encode_pubsub_error_item_required(Item_required, TopXMLNS); do_encode({ps_error, 'jid-required', _} = Jid_required, TopXMLNS) -> encode_pubsub_error_jid_required(Jid_required, TopXMLNS); do_encode({ps_error, 'max-items-exceeded', _} = Max_items_exceeded, TopXMLNS) -> encode_pubsub_error_max_items_exceeded(Max_items_exceeded, TopXMLNS); do_encode({ps_error, 'max-nodes-exceeded', _} = Max_nodes_exceeded, TopXMLNS) -> encode_pubsub_error_max_nodes_exceeded(Max_nodes_exceeded, TopXMLNS); do_encode({ps_error, 'nodeid-required', _} = Nodeid_required, TopXMLNS) -> encode_pubsub_error_nodeid_required(Nodeid_required, TopXMLNS); do_encode({ps_error, 'not-in-roster-group', _} = Not_in_roster_group, TopXMLNS) -> encode_pubsub_error_not_in_roster_group(Not_in_roster_group, TopXMLNS); do_encode({ps_error, 'not-subscribed', _} = Not_subscribed, TopXMLNS) -> encode_pubsub_error_not_subscribed(Not_subscribed, TopXMLNS); do_encode({ps_error, 'payload-too-big', _} = Payload_too_big, TopXMLNS) -> encode_pubsub_error_payload_too_big(Payload_too_big, TopXMLNS); do_encode({ps_error, 'payload-required', _} = Payload_required, TopXMLNS) -> encode_pubsub_error_payload_required(Payload_required, TopXMLNS); do_encode({ps_error, 'pending-subscription', _} = Pending_subscription, TopXMLNS) -> encode_pubsub_error_pending_subscription(Pending_subscription, TopXMLNS); do_encode({ps_error, 'precondition-not-met', _} = Precondition_not_met, TopXMLNS) -> encode_pubsub_error_precondition_not_met(Precondition_not_met, TopXMLNS); do_encode({ps_error, 'presence-subscription-required', _} = Presence_subscription_required, TopXMLNS) -> encode_pubsub_error_presence_subscription_required(Presence_subscription_required, TopXMLNS); do_encode({ps_error, 'subid-required', _} = Subid_required, TopXMLNS) -> encode_pubsub_error_subid_required(Subid_required, TopXMLNS); do_encode({ps_error, 'too-many-subscriptions', _} = Too_many_subscriptions, TopXMLNS) -> encode_pubsub_error_too_many_subscriptions(Too_many_subscriptions, TopXMLNS); do_encode({ps_error, unsupported, _} = Unsupported, TopXMLNS) -> encode_pubsub_error_unsupported(Unsupported, TopXMLNS); do_encode({ps_error, 'unsupported-access-model', _} = Unsupported_access_model, TopXMLNS) -> encode_pubsub_error_unsupported_access_model(Unsupported_access_model, TopXMLNS). do_get_name({ps_affiliation, _, _, _, _}) -> <<"affiliation">>; do_get_name({ps_error, 'closed-node', _}) -> <<"closed-node">>; do_get_name({ps_error, 'configuration-required', _}) -> <<"configuration-required">>; do_get_name({ps_error, 'invalid-jid', _}) -> <<"invalid-jid">>; do_get_name({ps_error, 'invalid-options', _}) -> <<"invalid-options">>; do_get_name({ps_error, 'invalid-payload', _}) -> <<"invalid-payload">>; do_get_name({ps_error, 'invalid-subid', _}) -> <<"invalid-subid">>; do_get_name({ps_error, 'item-forbidden', _}) -> <<"item-forbidden">>; do_get_name({ps_error, 'item-required', _}) -> <<"item-required">>; do_get_name({ps_error, 'jid-required', _}) -> <<"jid-required">>; do_get_name({ps_error, 'max-items-exceeded', _}) -> <<"max-items-exceeded">>; do_get_name({ps_error, 'max-nodes-exceeded', _}) -> <<"max-nodes-exceeded">>; do_get_name({ps_error, 'nodeid-required', _}) -> <<"nodeid-required">>; do_get_name({ps_error, 'not-in-roster-group', _}) -> <<"not-in-roster-group">>; do_get_name({ps_error, 'not-subscribed', _}) -> <<"not-subscribed">>; do_get_name({ps_error, 'payload-required', _}) -> <<"payload-required">>; do_get_name({ps_error, 'payload-too-big', _}) -> <<"payload-too-big">>; do_get_name({ps_error, 'pending-subscription', _}) -> <<"pending-subscription">>; do_get_name({ps_error, 'precondition-not-met', _}) -> <<"precondition-not-met">>; do_get_name({ps_error, 'presence-subscription-required', _}) -> <<"presence-subscription-required">>; do_get_name({ps_error, 'subid-required', _}) -> <<"subid-required">>; do_get_name({ps_error, 'too-many-subscriptions', _}) -> <<"too-many-subscriptions">>; do_get_name({ps_error, unsupported, _}) -> <<"unsupported">>; do_get_name({ps_error, 'unsupported-access-model', _}) -> <<"unsupported-access-model">>; do_get_name({ps_event, _, _, _, _, _, _}) -> <<"event">>; do_get_name({ps_item, _, _, _, _, _}) -> <<"item">>; do_get_name({ps_items, _, _, _, _, _, _}) -> <<"items">>; do_get_name({ps_options, _, _, _, _}) -> <<"options">>; do_get_name({ps_publish, _, _}) -> <<"publish">>; do_get_name({ps_retract, _, _, _}) -> <<"retract">>; do_get_name({ps_subscribe, _, _}) -> <<"subscribe">>; do_get_name({ps_subscription, _, _, _, _, _, _}) -> <<"subscription">>; do_get_name({ps_unsubscribe, _, _, _}) -> <<"unsubscribe">>; do_get_name({pubsub, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"pubsub">>; do_get_name({pubsub_owner, _, _, _, _, _, _}) -> <<"pubsub">>. do_get_ns({ps_affiliation, Xmlns, _, _, _}) -> Xmlns; do_get_ns({ps_error, 'closed-node', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'configuration-required', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'invalid-jid', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'invalid-options', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'invalid-payload', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'invalid-subid', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'item-forbidden', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'item-required', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'jid-required', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'max-items-exceeded', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'max-nodes-exceeded', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'nodeid-required', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'not-in-roster-group', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'not-subscribed', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'payload-required', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'payload-too-big', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'pending-subscription', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'precondition-not-met', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'presence-subscription-required', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'subid-required', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'too-many-subscriptions', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, unsupported, _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_error, 'unsupported-access-model', _}) -> <<"http://jabber.org/protocol/pubsub#errors">>; do_get_ns({ps_event, _, _, _, _, _, _}) -> <<"http://jabber.org/protocol/pubsub#event">>; do_get_ns({ps_item, Xmlns, _, _, _, _}) -> Xmlns; do_get_ns({ps_items, Xmlns, _, _, _, _, _}) -> Xmlns; do_get_ns({ps_options, _, _, _, _}) -> <<"http://jabber.org/protocol/pubsub">>; do_get_ns({ps_publish, _, _}) -> <<"http://jabber.org/protocol/pubsub">>; do_get_ns({ps_retract, _, _, _}) -> <<"http://jabber.org/protocol/pubsub">>; do_get_ns({ps_subscribe, _, _}) -> <<"http://jabber.org/protocol/pubsub">>; do_get_ns({ps_subscription, Xmlns, _, _, _, _, _}) -> Xmlns; do_get_ns({ps_unsubscribe, _, _, _}) -> <<"http://jabber.org/protocol/pubsub">>; do_get_ns({pubsub, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"http://jabber.org/protocol/pubsub">>; do_get_ns({pubsub_owner, _, _, _, _, _, _}) -> <<"http://jabber.org/protocol/pubsub#owner">>. get_els({ps_item, _xmlns, _id, _sub_els, _node, _publisher}) -> _sub_els. set_els({ps_item, _xmlns, _id, _, _node, _publisher}, _sub_els) -> {ps_item, _xmlns, _id, _sub_els, _node, _publisher}. pp(ps_subscription, 6) -> [xmlns, jid, type, node, subid, expiry]; pp(ps_affiliation, 4) -> [xmlns, node, type, jid]; pp(ps_item, 5) -> [xmlns, id, sub_els, node, publisher]; pp(ps_items, 6) -> [xmlns, node, items, max_items, subid, retract]; pp(ps_event, 6) -> [items, purge, subscription, delete, create, configuration]; pp(ps_subscribe, 2) -> [node, jid]; pp(ps_unsubscribe, 3) -> [node, jid, subid]; pp(ps_publish, 2) -> [node, items]; pp(ps_options, 4) -> [node, jid, subid, xdata]; pp(ps_retract, 3) -> [node, notify, items]; pp(pubsub, 16) -> [subscriptions, subscription, affiliations, publish, publish_options, subscribe, unsubscribe, options, items, retract, create, configure, default, delete, purge, rsm]; pp(pubsub_owner, 6) -> [affiliations, configure, default, delete, purge, subscriptions]; pp(ps_error, 2) -> [type, feature]; pp(_, _) -> no. records() -> [{ps_subscription, 6}, {ps_affiliation, 4}, {ps_item, 5}, {ps_items, 6}, {ps_event, 6}, {ps_subscribe, 2}, {ps_unsubscribe, 3}, {ps_publish, 2}, {ps_options, 4}, {ps_retract, 3}, {pubsub, 16}, {pubsub_owner, 6}, {ps_error, 2}]. dec_bool(<<"false">>) -> false; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"1">>) -> true. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. dec_ps_aff(<<"member">>) -> member; dec_ps_aff(<<"none">>) -> none; dec_ps_aff(<<"outcast">>) -> outcast; dec_ps_aff(<<"owner">>) -> owner; dec_ps_aff(<<"publisher">>) -> publisher; dec_ps_aff(<<"publish-only">>) -> publish_only. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_bool(false) -> <<"false">>; enc_bool(true) -> <<"true">>. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). enc_ps_aff(member) -> <<"member">>; enc_ps_aff(none) -> <<"none">>; enc_ps_aff(outcast) -> <<"outcast">>; enc_ps_aff(owner) -> <<"owner">>; enc_ps_aff(publisher) -> <<"publisher">>; enc_ps_aff(publish_only) -> <<"publish-only">>. enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_pubsub_error_unsupported_access_model(__TopXMLNS, __Opts, {xmlel, <<"unsupported-access-model">>, _attrs, _els}) -> {ps_error, 'unsupported-access-model', undefined}. encode_pubsub_error_unsupported_access_model({ps_error, 'unsupported-access-model', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-access-model">>, _attrs, _els}. decode_pubsub_error_unsupported(__TopXMLNS, __Opts, {xmlel, <<"unsupported">>, _attrs, _els}) -> Feature = decode_pubsub_error_unsupported_attrs(__TopXMLNS, _attrs, undefined), {ps_error, unsupported, Feature}. decode_pubsub_error_unsupported_attrs(__TopXMLNS, [{<<"feature">>, _val} | _attrs], _Feature) -> decode_pubsub_error_unsupported_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_error_unsupported_attrs(__TopXMLNS, [_ | _attrs], Feature) -> decode_pubsub_error_unsupported_attrs(__TopXMLNS, _attrs, Feature); decode_pubsub_error_unsupported_attrs(__TopXMLNS, [], Feature) -> decode_pubsub_error_unsupported_attr_feature(__TopXMLNS, Feature). encode_pubsub_error_unsupported({ps_error, unsupported, Feature}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = encode_pubsub_error_unsupported_attr_feature(Feature, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"unsupported">>, _attrs, _els}. decode_pubsub_error_unsupported_attr_feature(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"feature">>, <<"unsupported">>, __TopXMLNS}}); decode_pubsub_error_unsupported_attr_feature(__TopXMLNS, _val) -> case catch dec_enum(_val, ['access-authorize', 'access-open', 'access-presence', 'access-roster', 'access-whitelist', 'auto-create', 'auto-subscribe', collections, 'config-node', 'create-and-configure', 'create-nodes', 'delete-items', 'delete-nodes', 'filtered-notifications', 'get-pending', 'instant-nodes', 'item-ids', 'last-published', 'leased-subscription', 'manage-subscriptions', 'member-affiliation', 'meta-data', 'modify-affiliations', 'multi-collection', 'multi-items', 'multi-subscribe', 'outcast-affiliation', 'persistent-items', 'presence-notifications', 'presence-subscribe', publish, 'publish-options', 'publish-only-affiliation', 'publisher-affiliation', 'purge-nodes', 'retract-items', 'retrieve-affiliations', 'retrieve-default', 'retrieve-items', 'retrieve-subscriptions', subscribe, 'subscription-options', 'subscription-notifications']) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"feature">>, <<"unsupported">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_error_unsupported_attr_feature(_val, _acc) -> [{<<"feature">>, enc_enum(_val)} | _acc]. decode_pubsub_error_too_many_subscriptions(__TopXMLNS, __Opts, {xmlel, <<"too-many-subscriptions">>, _attrs, _els}) -> {ps_error, 'too-many-subscriptions', undefined}. encode_pubsub_error_too_many_subscriptions({ps_error, 'too-many-subscriptions', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"too-many-subscriptions">>, _attrs, _els}. decode_pubsub_error_subid_required(__TopXMLNS, __Opts, {xmlel, <<"subid-required">>, _attrs, _els}) -> {ps_error, 'subid-required', undefined}. encode_pubsub_error_subid_required({ps_error, 'subid-required', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"subid-required">>, _attrs, _els}. decode_pubsub_error_presence_subscription_required(__TopXMLNS, __Opts, {xmlel, <<"presence-subscription-required">>, _attrs, _els}) -> {ps_error, 'presence-subscription-required', undefined}. encode_pubsub_error_presence_subscription_required({ps_error, 'presence-subscription-required', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"presence-subscription-required">>, _attrs, _els}. decode_pubsub_error_precondition_not_met(__TopXMLNS, __Opts, {xmlel, <<"precondition-not-met">>, _attrs, _els}) -> {ps_error, 'precondition-not-met', undefined}. encode_pubsub_error_precondition_not_met({ps_error, 'precondition-not-met', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"precondition-not-met">>, _attrs, _els}. decode_pubsub_error_pending_subscription(__TopXMLNS, __Opts, {xmlel, <<"pending-subscription">>, _attrs, _els}) -> {ps_error, 'pending-subscription', undefined}. encode_pubsub_error_pending_subscription({ps_error, 'pending-subscription', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"pending-subscription">>, _attrs, _els}. decode_pubsub_error_payload_required(__TopXMLNS, __Opts, {xmlel, <<"payload-required">>, _attrs, _els}) -> {ps_error, 'payload-required', undefined}. encode_pubsub_error_payload_required({ps_error, 'payload-required', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"payload-required">>, _attrs, _els}. decode_pubsub_error_payload_too_big(__TopXMLNS, __Opts, {xmlel, <<"payload-too-big">>, _attrs, _els}) -> {ps_error, 'payload-too-big', undefined}. encode_pubsub_error_payload_too_big({ps_error, 'payload-too-big', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"payload-too-big">>, _attrs, _els}. decode_pubsub_error_not_subscribed(__TopXMLNS, __Opts, {xmlel, <<"not-subscribed">>, _attrs, _els}) -> {ps_error, 'not-subscribed', undefined}. encode_pubsub_error_not_subscribed({ps_error, 'not-subscribed', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-subscribed">>, _attrs, _els}. decode_pubsub_error_not_in_roster_group(__TopXMLNS, __Opts, {xmlel, <<"not-in-roster-group">>, _attrs, _els}) -> {ps_error, 'not-in-roster-group', undefined}. encode_pubsub_error_not_in_roster_group({ps_error, 'not-in-roster-group', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-in-roster-group">>, _attrs, _els}. decode_pubsub_error_nodeid_required(__TopXMLNS, __Opts, {xmlel, <<"nodeid-required">>, _attrs, _els}) -> {ps_error, 'nodeid-required', undefined}. encode_pubsub_error_nodeid_required({ps_error, 'nodeid-required', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"nodeid-required">>, _attrs, _els}. decode_pubsub_error_max_nodes_exceeded(__TopXMLNS, __Opts, {xmlel, <<"max-nodes-exceeded">>, _attrs, _els}) -> {ps_error, 'max-nodes-exceeded', undefined}. encode_pubsub_error_max_nodes_exceeded({ps_error, 'max-nodes-exceeded', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"max-nodes-exceeded">>, _attrs, _els}. decode_pubsub_error_max_items_exceeded(__TopXMLNS, __Opts, {xmlel, <<"max-items-exceeded">>, _attrs, _els}) -> {ps_error, 'max-items-exceeded', undefined}. encode_pubsub_error_max_items_exceeded({ps_error, 'max-items-exceeded', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"max-items-exceeded">>, _attrs, _els}. decode_pubsub_error_jid_required(__TopXMLNS, __Opts, {xmlel, <<"jid-required">>, _attrs, _els}) -> {ps_error, 'jid-required', undefined}. encode_pubsub_error_jid_required({ps_error, 'jid-required', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"jid-required">>, _attrs, _els}. decode_pubsub_error_item_required(__TopXMLNS, __Opts, {xmlel, <<"item-required">>, _attrs, _els}) -> {ps_error, 'item-required', undefined}. encode_pubsub_error_item_required({ps_error, 'item-required', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"item-required">>, _attrs, _els}. decode_pubsub_error_item_forbidden(__TopXMLNS, __Opts, {xmlel, <<"item-forbidden">>, _attrs, _els}) -> {ps_error, 'item-forbidden', undefined}. encode_pubsub_error_item_forbidden({ps_error, 'item-forbidden', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"item-forbidden">>, _attrs, _els}. decode_pubsub_error_invalid_subid(__TopXMLNS, __Opts, {xmlel, <<"invalid-subid">>, _attrs, _els}) -> {ps_error, 'invalid-subid', undefined}. encode_pubsub_error_invalid_subid({ps_error, 'invalid-subid', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-subid">>, _attrs, _els}. decode_pubsub_error_invalid_payload(__TopXMLNS, __Opts, {xmlel, <<"invalid-payload">>, _attrs, _els}) -> {ps_error, 'invalid-payload', undefined}. encode_pubsub_error_invalid_payload({ps_error, 'invalid-payload', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-payload">>, _attrs, _els}. decode_pubsub_error_invalid_options(__TopXMLNS, __Opts, {xmlel, <<"invalid-options">>, _attrs, _els}) -> {ps_error, 'invalid-options', undefined}. encode_pubsub_error_invalid_options({ps_error, 'invalid-options', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-options">>, _attrs, _els}. decode_pubsub_error_invalid_jid(__TopXMLNS, __Opts, {xmlel, <<"invalid-jid">>, _attrs, _els}) -> {ps_error, 'invalid-jid', undefined}. encode_pubsub_error_invalid_jid({ps_error, 'invalid-jid', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-jid">>, _attrs, _els}. decode_pubsub_error_configuration_required(__TopXMLNS, __Opts, {xmlel, <<"configuration-required">>, _attrs, _els}) -> {ps_error, 'configuration-required', undefined}. encode_pubsub_error_configuration_required({ps_error, 'configuration-required', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"configuration-required">>, _attrs, _els}. decode_pubsub_error_closed_node(__TopXMLNS, __Opts, {xmlel, <<"closed-node">>, _attrs, _els}) -> {ps_error, 'closed-node', undefined}. encode_pubsub_error_closed_node({ps_error, 'closed-node', _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#errors">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"closed-node">>, _attrs, _els}. decode_pubsub_owner(__TopXMLNS, __Opts, {xmlel, <<"pubsub">>, _attrs, _els}) -> {Subscriptions, Affiliations, Default, Purge, Delete, Configure} = decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined, undefined, undefined), {pubsub_owner, Affiliations, Configure, Default, Delete, Purge, Subscriptions}. decode_pubsub_owner_els(__TopXMLNS, __Opts, [], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> {Subscriptions, Affiliations, Default, Purge, Delete, Configure}; decode_pubsub_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"affiliations">>, _attrs, _} = _el | _els], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, decode_pubsub_owner_affiliations(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Default, Purge, Delete, Configure); _ -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, Configure) end; decode_pubsub_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"configure">>, _attrs, _} = _el | _els], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, decode_pubsub_configure(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el)); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, decode_pubsub_configure(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el)); _ -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, Configure) end; decode_pubsub_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"default">>, _attrs, _} = _el | _els], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, decode_pubsub_default(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Purge, Delete, Configure); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, decode_pubsub_default(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Purge, Delete, Configure); _ -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, Configure) end; decode_pubsub_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"delete">>, _attrs, _} = _el | _els], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Configure); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Configure); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Configure); _ -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, Configure) end; decode_pubsub_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"purge">>, _attrs, _} = _el | _els], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Delete, Configure); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Delete, Configure); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Delete, Configure); _ -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, Configure) end; decode_pubsub_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"subscriptions">>, _attrs, _} = _el | _els], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, decode_pubsub_subscriptions(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Affiliations, Default, Purge, Delete, Configure); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, decode_pubsub_subscriptions(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Affiliations, Default, Purge, Delete, Configure); _ -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, Configure) end; decode_pubsub_owner_els(__TopXMLNS, __Opts, [_ | _els], Subscriptions, Affiliations, Default, Purge, Delete, Configure) -> decode_pubsub_owner_els(__TopXMLNS, __Opts, _els, Subscriptions, Affiliations, Default, Purge, Delete, Configure). encode_pubsub_owner({pubsub_owner, Affiliations, Configure, Default, Delete, Purge, Subscriptions}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#owner">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_owner_$subscriptions'(Subscriptions, __NewTopXMLNS, 'encode_pubsub_owner_$affiliations'(Affiliations, __NewTopXMLNS, 'encode_pubsub_owner_$default'(Default, __NewTopXMLNS, 'encode_pubsub_owner_$purge'(Purge, __NewTopXMLNS, 'encode_pubsub_owner_$delete'(Delete, __NewTopXMLNS, 'encode_pubsub_owner_$configure'(Configure, __NewTopXMLNS, []))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"pubsub">>, _attrs, _els}. 'encode_pubsub_owner_$subscriptions'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_owner_$subscriptions'(Subscriptions, __TopXMLNS, _acc) -> [encode_pubsub_subscriptions(Subscriptions, __TopXMLNS) | _acc]. 'encode_pubsub_owner_$affiliations'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_owner_$affiliations'(Affiliations, __TopXMLNS, _acc) -> [encode_pubsub_owner_affiliations(Affiliations, __TopXMLNS) | _acc]. 'encode_pubsub_owner_$default'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_owner_$default'(Default, __TopXMLNS, _acc) -> [encode_pubsub_default(Default, __TopXMLNS) | _acc]. 'encode_pubsub_owner_$purge'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_owner_$purge'(Purge, __TopXMLNS, _acc) -> [encode_pubsub_purge(Purge, __TopXMLNS) | _acc]. 'encode_pubsub_owner_$delete'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_owner_$delete'(Delete, __TopXMLNS, _acc) -> [encode_pubsub_delete(Delete, __TopXMLNS) | _acc]. 'encode_pubsub_owner_$configure'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_owner_$configure'(Configure, __TopXMLNS, _acc) -> [encode_pubsub_configure(Configure, __TopXMLNS) | _acc]. decode_pubsub(__TopXMLNS, __Opts, {xmlel, <<"pubsub">>, _attrs, _els}) -> {Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription} = decode_pubsub_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined), {pubsub, Subscriptions, Subscription, Affiliations, Publish, Publish_options, Subscribe, Unsubscribe, Options, Items, Retract, Create, Configure, Default, Delete, Purge, Rsm}. decode_pubsub_els(__TopXMLNS, __Opts, [], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> {Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription}; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"subscriptions">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, decode_pubsub_subscriptions(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, decode_pubsub_subscriptions(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"affiliations">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, decode_pubsub_affiliations(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"subscribe">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, decode_pubsub_subscribe(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"unsubscribe">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, decode_pubsub_unsubscribe(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"options">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, decode_pubsub_options(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"items">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, decode_pubsub_items(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, decode_pubsub_items(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"retract">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, decode_pubsub_retract(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"create">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, decode_pubsub_create(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, decode_pubsub_create(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"configure">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, decode_pubsub_configure(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, decode_pubsub_configure(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"publish-options">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, decode_pubsub_publish_options(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"default">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, decode_pubsub_default(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, decode_pubsub_default(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"delete">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"purge">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"subscription">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el)); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el)); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el)); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"set">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, xep0059:decode_rsm_set(<<"http://jabber.org/protocol/rsm">>, __Opts, _el), Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [{xmlel, <<"publish">>, _attrs, _} = _el | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, decode_pubsub_publish(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Rsm, Subscription); _ -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) end; decode_pubsub_els(__TopXMLNS, __Opts, [_ | _els], Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription) -> decode_pubsub_els(__TopXMLNS, __Opts, _els, Publish_options, Items, Options, Affiliations, Subscriptions, Default, Retract, Purge, Delete, Configure, Create, Unsubscribe, Subscribe, Publish, Rsm, Subscription). encode_pubsub({pubsub, Subscriptions, Subscription, Affiliations, Publish, Publish_options, Subscribe, Unsubscribe, Options, Items, Retract, Create, Configure, Default, Delete, Purge, Rsm}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_$publish_options'(Publish_options, __NewTopXMLNS, 'encode_pubsub_$items'(Items, __NewTopXMLNS, 'encode_pubsub_$options'(Options, __NewTopXMLNS, 'encode_pubsub_$affiliations'(Affiliations, __NewTopXMLNS, 'encode_pubsub_$subscriptions'(Subscriptions, __NewTopXMLNS, 'encode_pubsub_$default'(Default, __NewTopXMLNS, 'encode_pubsub_$retract'(Retract, __NewTopXMLNS, 'encode_pubsub_$purge'(Purge, __NewTopXMLNS, 'encode_pubsub_$delete'(Delete, __NewTopXMLNS, 'encode_pubsub_$configure'(Configure, __NewTopXMLNS, 'encode_pubsub_$create'(Create, __NewTopXMLNS, 'encode_pubsub_$unsubscribe'(Unsubscribe, __NewTopXMLNS, 'encode_pubsub_$subscribe'(Subscribe, __NewTopXMLNS, 'encode_pubsub_$publish'(Publish, __NewTopXMLNS, 'encode_pubsub_$rsm'(Rsm, __NewTopXMLNS, 'encode_pubsub_$subscription'(Subscription, __NewTopXMLNS, []))))))))))))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"pubsub">>, _attrs, _els}. 'encode_pubsub_$publish_options'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$publish_options'(Publish_options, __TopXMLNS, _acc) -> [encode_pubsub_publish_options(Publish_options, __TopXMLNS) | _acc]. 'encode_pubsub_$items'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$items'(Items, __TopXMLNS, _acc) -> [encode_pubsub_items(Items, __TopXMLNS) | _acc]. 'encode_pubsub_$options'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$options'(Options, __TopXMLNS, _acc) -> [encode_pubsub_options(Options, __TopXMLNS) | _acc]. 'encode_pubsub_$affiliations'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$affiliations'(Affiliations, __TopXMLNS, _acc) -> [encode_pubsub_affiliations(Affiliations, __TopXMLNS) | _acc]. 'encode_pubsub_$subscriptions'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$subscriptions'(Subscriptions, __TopXMLNS, _acc) -> [encode_pubsub_subscriptions(Subscriptions, __TopXMLNS) | _acc]. 'encode_pubsub_$default'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$default'(Default, __TopXMLNS, _acc) -> [encode_pubsub_default(Default, __TopXMLNS) | _acc]. 'encode_pubsub_$retract'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$retract'(Retract, __TopXMLNS, _acc) -> [encode_pubsub_retract(Retract, __TopXMLNS) | _acc]. 'encode_pubsub_$purge'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$purge'(Purge, __TopXMLNS, _acc) -> [encode_pubsub_purge(Purge, __TopXMLNS) | _acc]. 'encode_pubsub_$delete'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$delete'(Delete, __TopXMLNS, _acc) -> [encode_pubsub_delete(Delete, __TopXMLNS) | _acc]. 'encode_pubsub_$configure'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$configure'(Configure, __TopXMLNS, _acc) -> [encode_pubsub_configure(Configure, __TopXMLNS) | _acc]. 'encode_pubsub_$create'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$create'(Create, __TopXMLNS, _acc) -> [encode_pubsub_create(Create, __TopXMLNS) | _acc]. 'encode_pubsub_$unsubscribe'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$unsubscribe'(Unsubscribe, __TopXMLNS, _acc) -> [encode_pubsub_unsubscribe(Unsubscribe, __TopXMLNS) | _acc]. 'encode_pubsub_$subscribe'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$subscribe'(Subscribe, __TopXMLNS, _acc) -> [encode_pubsub_subscribe(Subscribe, __TopXMLNS) | _acc]. 'encode_pubsub_$publish'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$publish'(Publish, __TopXMLNS, _acc) -> [encode_pubsub_publish(Publish, __TopXMLNS) | _acc]. 'encode_pubsub_$rsm'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$rsm'(Rsm, __TopXMLNS, _acc) -> [xep0059:encode_rsm_set(Rsm, __TopXMLNS) | _acc]. 'encode_pubsub_$subscription'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_$subscription'(Subscription, __TopXMLNS, _acc) -> [encode_pubsub_subscription(Subscription, __TopXMLNS) | _acc]. decode_pubsub_purge(__TopXMLNS, __Opts, {xmlel, <<"purge">>, _attrs, _els}) -> Node = decode_pubsub_purge_attrs(__TopXMLNS, _attrs, undefined), Node. decode_pubsub_purge_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_purge_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_purge_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_purge_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_purge_attrs(__TopXMLNS, [], Node) -> decode_pubsub_purge_attr_node(__TopXMLNS, Node). encode_pubsub_purge(Node, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], __TopXMLNS), _els = [], _attrs = encode_pubsub_purge_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"purge">>, _attrs, _els}. decode_pubsub_purge_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"purge">>, __TopXMLNS}}); decode_pubsub_purge_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_purge_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_delete(__TopXMLNS, __Opts, {xmlel, <<"delete">>, _attrs, _els}) -> Uri = decode_pubsub_delete_els(__TopXMLNS, __Opts, _els, <<>>), Node = decode_pubsub_delete_attrs(__TopXMLNS, _attrs, undefined), {Node, Uri}. decode_pubsub_delete_els(__TopXMLNS, __Opts, [], Uri) -> Uri; decode_pubsub_delete_els(__TopXMLNS, __Opts, [{xmlel, <<"redirect">>, _attrs, _} = _el | _els], Uri) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_delete_els(__TopXMLNS, __Opts, _els, decode_pubsub_redirect(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el)); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_delete_els(__TopXMLNS, __Opts, _els, decode_pubsub_redirect(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el)); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_delete_els(__TopXMLNS, __Opts, _els, decode_pubsub_redirect(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el)); _ -> decode_pubsub_delete_els(__TopXMLNS, __Opts, _els, Uri) end; decode_pubsub_delete_els(__TopXMLNS, __Opts, [_ | _els], Uri) -> decode_pubsub_delete_els(__TopXMLNS, __Opts, _els, Uri). decode_pubsub_delete_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_delete_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_delete_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_delete_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_delete_attrs(__TopXMLNS, [], Node) -> decode_pubsub_delete_attr_node(__TopXMLNS, Node). encode_pubsub_delete({Node, Uri}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], __TopXMLNS), _els = lists:reverse('encode_pubsub_delete_$uri'(Uri, __NewTopXMLNS, [])), _attrs = encode_pubsub_delete_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"delete">>, _attrs, _els}. 'encode_pubsub_delete_$uri'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_delete_$uri'(Uri, __TopXMLNS, _acc) -> [encode_pubsub_redirect(Uri, __TopXMLNS) | _acc]. decode_pubsub_delete_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"delete">>, __TopXMLNS}}); decode_pubsub_delete_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_delete_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_redirect(__TopXMLNS, __Opts, {xmlel, <<"redirect">>, _attrs, _els}) -> Uri = decode_pubsub_redirect_attrs(__TopXMLNS, _attrs, undefined), Uri. decode_pubsub_redirect_attrs(__TopXMLNS, [{<<"uri">>, _val} | _attrs], _Uri) -> decode_pubsub_redirect_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_redirect_attrs(__TopXMLNS, [_ | _attrs], Uri) -> decode_pubsub_redirect_attrs(__TopXMLNS, _attrs, Uri); decode_pubsub_redirect_attrs(__TopXMLNS, [], Uri) -> decode_pubsub_redirect_attr_uri(__TopXMLNS, Uri). encode_pubsub_redirect(Uri, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], __TopXMLNS), _els = [], _attrs = encode_pubsub_redirect_attr_uri(Uri, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"redirect">>, _attrs, _els}. decode_pubsub_redirect_attr_uri(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"uri">>, <<"redirect">>, __TopXMLNS}}); decode_pubsub_redirect_attr_uri(__TopXMLNS, _val) -> _val. encode_pubsub_redirect_attr_uri(_val, _acc) -> [{<<"uri">>, _val} | _acc]. decode_pubsub_default(__TopXMLNS, __Opts, {xmlel, <<"default">>, _attrs, _els}) -> Xdata = decode_pubsub_default_els(__TopXMLNS, __Opts, _els, undefined), Node = decode_pubsub_default_attrs(__TopXMLNS, _attrs, undefined), {Node, Xdata}. decode_pubsub_default_els(__TopXMLNS, __Opts, [], Xdata) -> Xdata; decode_pubsub_default_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_pubsub_default_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_pubsub_default_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_pubsub_default_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_pubsub_default_els(__TopXMLNS, __Opts, _els, Xdata). decode_pubsub_default_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_default_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_default_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_default_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_default_attrs(__TopXMLNS, [], Node) -> decode_pubsub_default_attr_node(__TopXMLNS, Node). encode_pubsub_default({Node, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>], __TopXMLNS), _els = lists:reverse('encode_pubsub_default_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = encode_pubsub_default_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"default">>, _attrs, _els}. 'encode_pubsub_default_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_default_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. decode_pubsub_default_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_default_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_default_attr_node(<<>>, _acc) -> _acc; encode_pubsub_default_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_publish_options(__TopXMLNS, __Opts, {xmlel, <<"publish-options">>, _attrs, _els}) -> Xdata = decode_pubsub_publish_options_els(__TopXMLNS, __Opts, _els, undefined), Xdata. decode_pubsub_publish_options_els(__TopXMLNS, __Opts, [], Xdata) -> Xdata; decode_pubsub_publish_options_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_pubsub_publish_options_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_pubsub_publish_options_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_pubsub_publish_options_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_pubsub_publish_options_els(__TopXMLNS, __Opts, _els, Xdata). encode_pubsub_publish_options(Xdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_publish_options_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"publish-options">>, _attrs, _els}. 'encode_pubsub_publish_options_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_publish_options_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. decode_pubsub_configure(__TopXMLNS, __Opts, {xmlel, <<"configure">>, _attrs, _els}) -> Xdata = decode_pubsub_configure_els(__TopXMLNS, __Opts, _els, undefined), Node = decode_pubsub_configure_attrs(__TopXMLNS, _attrs, undefined), {Node, Xdata}. decode_pubsub_configure_els(__TopXMLNS, __Opts, [], Xdata) -> Xdata; decode_pubsub_configure_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_pubsub_configure_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_pubsub_configure_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_pubsub_configure_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_pubsub_configure_els(__TopXMLNS, __Opts, _els, Xdata). decode_pubsub_configure_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_configure_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_configure_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_configure_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_configure_attrs(__TopXMLNS, [], Node) -> decode_pubsub_configure_attr_node(__TopXMLNS, Node). encode_pubsub_configure({Node, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>], __TopXMLNS), _els = lists:reverse('encode_pubsub_configure_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = encode_pubsub_configure_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"configure">>, _attrs, _els}. 'encode_pubsub_configure_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_configure_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. decode_pubsub_configure_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_configure_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_configure_attr_node(<<>>, _acc) -> _acc; encode_pubsub_configure_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_create(__TopXMLNS, __Opts, {xmlel, <<"create">>, _attrs, _els}) -> Node = decode_pubsub_create_attrs(__TopXMLNS, _attrs, undefined), Node. decode_pubsub_create_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_create_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_create_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_create_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_create_attrs(__TopXMLNS, [], Node) -> decode_pubsub_create_attr_node(__TopXMLNS, Node). encode_pubsub_create(Node, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#event">>], __TopXMLNS), _els = [], _attrs = encode_pubsub_create_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"create">>, _attrs, _els}. decode_pubsub_create_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_create_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_create_attr_node(<<>>, _acc) -> _acc; encode_pubsub_create_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_retract(__TopXMLNS, __Opts, {xmlel, <<"retract">>, _attrs, _els}) -> Items = decode_pubsub_retract_els(__TopXMLNS, __Opts, _els, []), {Node, Notify} = decode_pubsub_retract_attrs(__TopXMLNS, _attrs, undefined, undefined), {ps_retract, Node, Notify, Items}. decode_pubsub_retract_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_pubsub_retract_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_retract_els(__TopXMLNS, __Opts, _els, [decode_pubsub_item(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el) | Items]); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_retract_els(__TopXMLNS, __Opts, _els, [decode_pubsub_item(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el) | Items]); _ -> decode_pubsub_retract_els(__TopXMLNS, __Opts, _els, Items) end; decode_pubsub_retract_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_pubsub_retract_els(__TopXMLNS, __Opts, _els, Items). decode_pubsub_retract_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node, Notify) -> decode_pubsub_retract_attrs(__TopXMLNS, _attrs, _val, Notify); decode_pubsub_retract_attrs(__TopXMLNS, [{<<"notify">>, _val} | _attrs], Node, _Notify) -> decode_pubsub_retract_attrs(__TopXMLNS, _attrs, Node, _val); decode_pubsub_retract_attrs(__TopXMLNS, [_ | _attrs], Node, Notify) -> decode_pubsub_retract_attrs(__TopXMLNS, _attrs, Node, Notify); decode_pubsub_retract_attrs(__TopXMLNS, [], Node, Notify) -> {decode_pubsub_retract_attr_node(__TopXMLNS, Node), decode_pubsub_retract_attr_notify(__TopXMLNS, Notify)}. encode_pubsub_retract({ps_retract, Node, Notify, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_retract_$items'(Items, __NewTopXMLNS, [])), _attrs = encode_pubsub_retract_attr_notify(Notify, encode_pubsub_retract_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"retract">>, _attrs, _els}. 'encode_pubsub_retract_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_pubsub_retract_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_pubsub_retract_$items'(_els, __TopXMLNS, [encode_pubsub_item(Items, __TopXMLNS) | _acc]). decode_pubsub_retract_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"retract">>, __TopXMLNS}}); decode_pubsub_retract_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_retract_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_retract_attr_notify(__TopXMLNS, undefined) -> false; decode_pubsub_retract_attr_notify(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"notify">>, <<"retract">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_retract_attr_notify(false, _acc) -> _acc; encode_pubsub_retract_attr_notify(_val, _acc) -> [{<<"notify">>, enc_bool(_val)} | _acc]. decode_pubsub_options(__TopXMLNS, __Opts, {xmlel, <<"options">>, _attrs, _els}) -> Xdata = decode_pubsub_options_els(__TopXMLNS, __Opts, _els, undefined), {Node, Subid, Jid} = decode_pubsub_options_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {ps_options, Node, Jid, Subid, Xdata}. decode_pubsub_options_els(__TopXMLNS, __Opts, [], Xdata) -> Xdata; decode_pubsub_options_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_pubsub_options_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_pubsub_options_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_pubsub_options_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_pubsub_options_els(__TopXMLNS, __Opts, _els, Xdata). decode_pubsub_options_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node, Subid, Jid) -> decode_pubsub_options_attrs(__TopXMLNS, _attrs, _val, Subid, Jid); decode_pubsub_options_attrs(__TopXMLNS, [{<<"subid">>, _val} | _attrs], Node, _Subid, Jid) -> decode_pubsub_options_attrs(__TopXMLNS, _attrs, Node, _val, Jid); decode_pubsub_options_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Node, Subid, _Jid) -> decode_pubsub_options_attrs(__TopXMLNS, _attrs, Node, Subid, _val); decode_pubsub_options_attrs(__TopXMLNS, [_ | _attrs], Node, Subid, Jid) -> decode_pubsub_options_attrs(__TopXMLNS, _attrs, Node, Subid, Jid); decode_pubsub_options_attrs(__TopXMLNS, [], Node, Subid, Jid) -> {decode_pubsub_options_attr_node(__TopXMLNS, Node), decode_pubsub_options_attr_subid(__TopXMLNS, Subid), decode_pubsub_options_attr_jid(__TopXMLNS, Jid)}. encode_pubsub_options({ps_options, Node, Jid, Subid, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_options_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = encode_pubsub_options_attr_jid(Jid, encode_pubsub_options_attr_subid(Subid, encode_pubsub_options_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"options">>, _attrs, _els}. 'encode_pubsub_options_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_options_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. decode_pubsub_options_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_options_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_options_attr_node(<<>>, _acc) -> _acc; encode_pubsub_options_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_options_attr_subid(__TopXMLNS, undefined) -> <<>>; decode_pubsub_options_attr_subid(__TopXMLNS, _val) -> _val. encode_pubsub_options_attr_subid(<<>>, _acc) -> _acc; encode_pubsub_options_attr_subid(_val, _acc) -> [{<<"subid">>, _val} | _acc]. decode_pubsub_options_attr_jid(__TopXMLNS, undefined) -> undefined; decode_pubsub_options_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"options">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_options_attr_jid(undefined, _acc) -> _acc; encode_pubsub_options_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_pubsub_publish(__TopXMLNS, __Opts, {xmlel, <<"publish">>, _attrs, _els}) -> Items = decode_pubsub_publish_els(__TopXMLNS, __Opts, _els, []), Node = decode_pubsub_publish_attrs(__TopXMLNS, _attrs, undefined), {ps_publish, Node, Items}. decode_pubsub_publish_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_pubsub_publish_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_publish_els(__TopXMLNS, __Opts, _els, [decode_pubsub_item(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el) | Items]); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_publish_els(__TopXMLNS, __Opts, _els, [decode_pubsub_item(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el) | Items]); _ -> decode_pubsub_publish_els(__TopXMLNS, __Opts, _els, Items) end; decode_pubsub_publish_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_pubsub_publish_els(__TopXMLNS, __Opts, _els, Items). decode_pubsub_publish_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_publish_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_publish_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_publish_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_publish_attrs(__TopXMLNS, [], Node) -> decode_pubsub_publish_attr_node(__TopXMLNS, Node). encode_pubsub_publish({ps_publish, Node, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_publish_$items'(Items, __NewTopXMLNS, [])), _attrs = encode_pubsub_publish_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"publish">>, _attrs, _els}. 'encode_pubsub_publish_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_pubsub_publish_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_pubsub_publish_$items'(_els, __TopXMLNS, [encode_pubsub_item(Items, __TopXMLNS) | _acc]). decode_pubsub_publish_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"publish">>, __TopXMLNS}}); decode_pubsub_publish_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_publish_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_unsubscribe(__TopXMLNS, __Opts, {xmlel, <<"unsubscribe">>, _attrs, _els}) -> {Node, Subid, Jid} = decode_pubsub_unsubscribe_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {ps_unsubscribe, Node, Jid, Subid}. decode_pubsub_unsubscribe_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node, Subid, Jid) -> decode_pubsub_unsubscribe_attrs(__TopXMLNS, _attrs, _val, Subid, Jid); decode_pubsub_unsubscribe_attrs(__TopXMLNS, [{<<"subid">>, _val} | _attrs], Node, _Subid, Jid) -> decode_pubsub_unsubscribe_attrs(__TopXMLNS, _attrs, Node, _val, Jid); decode_pubsub_unsubscribe_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Node, Subid, _Jid) -> decode_pubsub_unsubscribe_attrs(__TopXMLNS, _attrs, Node, Subid, _val); decode_pubsub_unsubscribe_attrs(__TopXMLNS, [_ | _attrs], Node, Subid, Jid) -> decode_pubsub_unsubscribe_attrs(__TopXMLNS, _attrs, Node, Subid, Jid); decode_pubsub_unsubscribe_attrs(__TopXMLNS, [], Node, Subid, Jid) -> {decode_pubsub_unsubscribe_attr_node(__TopXMLNS, Node), decode_pubsub_unsubscribe_attr_subid(__TopXMLNS, Subid), decode_pubsub_unsubscribe_attr_jid(__TopXMLNS, Jid)}. encode_pubsub_unsubscribe({ps_unsubscribe, Node, Jid, Subid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = [], _attrs = encode_pubsub_unsubscribe_attr_jid(Jid, encode_pubsub_unsubscribe_attr_subid(Subid, encode_pubsub_unsubscribe_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"unsubscribe">>, _attrs, _els}. decode_pubsub_unsubscribe_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_unsubscribe_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_unsubscribe_attr_node(<<>>, _acc) -> _acc; encode_pubsub_unsubscribe_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_unsubscribe_attr_subid(__TopXMLNS, undefined) -> <<>>; decode_pubsub_unsubscribe_attr_subid(__TopXMLNS, _val) -> _val. encode_pubsub_unsubscribe_attr_subid(<<>>, _acc) -> _acc; encode_pubsub_unsubscribe_attr_subid(_val, _acc) -> [{<<"subid">>, _val} | _acc]. decode_pubsub_unsubscribe_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"unsubscribe">>, __TopXMLNS}}); decode_pubsub_unsubscribe_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"unsubscribe">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_unsubscribe_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_pubsub_subscribe(__TopXMLNS, __Opts, {xmlel, <<"subscribe">>, _attrs, _els}) -> {Node, Jid} = decode_pubsub_subscribe_attrs(__TopXMLNS, _attrs, undefined, undefined), {ps_subscribe, Node, Jid}. decode_pubsub_subscribe_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node, Jid) -> decode_pubsub_subscribe_attrs(__TopXMLNS, _attrs, _val, Jid); decode_pubsub_subscribe_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Node, _Jid) -> decode_pubsub_subscribe_attrs(__TopXMLNS, _attrs, Node, _val); decode_pubsub_subscribe_attrs(__TopXMLNS, [_ | _attrs], Node, Jid) -> decode_pubsub_subscribe_attrs(__TopXMLNS, _attrs, Node, Jid); decode_pubsub_subscribe_attrs(__TopXMLNS, [], Node, Jid) -> {decode_pubsub_subscribe_attr_node(__TopXMLNS, Node), decode_pubsub_subscribe_attr_jid(__TopXMLNS, Jid)}. encode_pubsub_subscribe({ps_subscribe, Node, Jid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = [], _attrs = encode_pubsub_subscribe_attr_jid(Jid, encode_pubsub_subscribe_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"subscribe">>, _attrs, _els}. decode_pubsub_subscribe_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_subscribe_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_subscribe_attr_node(<<>>, _acc) -> _acc; encode_pubsub_subscribe_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_subscribe_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"subscribe">>, __TopXMLNS}}); decode_pubsub_subscribe_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"subscribe">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_subscribe_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_pubsub_owner_affiliations(__TopXMLNS, __Opts, {xmlel, <<"affiliations">>, _attrs, _els}) -> Affiliations = decode_pubsub_owner_affiliations_els(__TopXMLNS, __Opts, _els, []), Node = decode_pubsub_owner_affiliations_attrs(__TopXMLNS, _attrs, undefined), {Node, Affiliations}. decode_pubsub_owner_affiliations_els(__TopXMLNS, __Opts, [], Affiliations) -> lists:reverse(Affiliations); decode_pubsub_owner_affiliations_els(__TopXMLNS, __Opts, [{xmlel, <<"affiliation">>, _attrs, _} = _el | _els], Affiliations) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_owner_affiliations_els(__TopXMLNS, __Opts, _els, [decode_pubsub_owner_affiliation(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el) | Affiliations]); _ -> decode_pubsub_owner_affiliations_els(__TopXMLNS, __Opts, _els, Affiliations) end; decode_pubsub_owner_affiliations_els(__TopXMLNS, __Opts, [_ | _els], Affiliations) -> decode_pubsub_owner_affiliations_els(__TopXMLNS, __Opts, _els, Affiliations). decode_pubsub_owner_affiliations_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_owner_affiliations_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_owner_affiliations_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_owner_affiliations_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_owner_affiliations_attrs(__TopXMLNS, [], Node) -> decode_pubsub_owner_affiliations_attr_node(__TopXMLNS, Node). encode_pubsub_owner_affiliations({Node, Affiliations}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#owner">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_owner_affiliations_$affiliations'(Affiliations, __NewTopXMLNS, [])), _attrs = encode_pubsub_owner_affiliations_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"affiliations">>, _attrs, _els}. 'encode_pubsub_owner_affiliations_$affiliations'([], __TopXMLNS, _acc) -> _acc; 'encode_pubsub_owner_affiliations_$affiliations'([Affiliations | _els], __TopXMLNS, _acc) -> 'encode_pubsub_owner_affiliations_$affiliations'(_els, __TopXMLNS, [encode_pubsub_owner_affiliation(Affiliations, __TopXMLNS) | _acc]). decode_pubsub_owner_affiliations_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_owner_affiliations_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_owner_affiliations_attr_node(<<>>, _acc) -> _acc; encode_pubsub_owner_affiliations_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_affiliations(__TopXMLNS, __Opts, {xmlel, <<"affiliations">>, _attrs, _els}) -> Affiliations = decode_pubsub_affiliations_els(__TopXMLNS, __Opts, _els, []), Node = decode_pubsub_affiliations_attrs(__TopXMLNS, _attrs, undefined), {Node, Affiliations}. decode_pubsub_affiliations_els(__TopXMLNS, __Opts, [], Affiliations) -> lists:reverse(Affiliations); decode_pubsub_affiliations_els(__TopXMLNS, __Opts, [{xmlel, <<"affiliation">>, _attrs, _} = _el | _els], Affiliations) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_affiliations_els(__TopXMLNS, __Opts, _els, [decode_pubsub_affiliation(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el) | Affiliations]); _ -> decode_pubsub_affiliations_els(__TopXMLNS, __Opts, _els, Affiliations) end; decode_pubsub_affiliations_els(__TopXMLNS, __Opts, [_ | _els], Affiliations) -> decode_pubsub_affiliations_els(__TopXMLNS, __Opts, _els, Affiliations). decode_pubsub_affiliations_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_affiliations_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_affiliations_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_affiliations_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_affiliations_attrs(__TopXMLNS, [], Node) -> decode_pubsub_affiliations_attr_node(__TopXMLNS, Node). encode_pubsub_affiliations({Node, Affiliations}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_affiliations_$affiliations'(Affiliations, __NewTopXMLNS, [])), _attrs = encode_pubsub_affiliations_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"affiliations">>, _attrs, _els}. 'encode_pubsub_affiliations_$affiliations'([], __TopXMLNS, _acc) -> _acc; 'encode_pubsub_affiliations_$affiliations'([Affiliations | _els], __TopXMLNS, _acc) -> 'encode_pubsub_affiliations_$affiliations'(_els, __TopXMLNS, [encode_pubsub_affiliation(Affiliations, __TopXMLNS) | _acc]). decode_pubsub_affiliations_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_affiliations_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_affiliations_attr_node(<<>>, _acc) -> _acc; encode_pubsub_affiliations_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_subscriptions(__TopXMLNS, __Opts, {xmlel, <<"subscriptions">>, _attrs, _els}) -> Subscriptions = decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, _els, []), Node = decode_pubsub_subscriptions_attrs(__TopXMLNS, _attrs, undefined), {Node, Subscriptions}. decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, [], Subscriptions) -> lists:reverse(Subscriptions); decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, [{xmlel, <<"subscription">>, _attrs, _} = _el | _els], Subscriptions) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, _els, [decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el) | Subscriptions]); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, _els, [decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el) | Subscriptions]); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, _els, [decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el) | Subscriptions]); _ -> decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, _els, Subscriptions) end; decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, [_ | _els], Subscriptions) -> decode_pubsub_subscriptions_els(__TopXMLNS, __Opts, _els, Subscriptions). decode_pubsub_subscriptions_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_subscriptions_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_subscriptions_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_subscriptions_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_subscriptions_attrs(__TopXMLNS, [], Node) -> decode_pubsub_subscriptions_attr_node(__TopXMLNS, Node). encode_pubsub_subscriptions({Node, Subscriptions}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>], __TopXMLNS), _els = lists:reverse('encode_pubsub_subscriptions_$subscriptions'(Subscriptions, __NewTopXMLNS, [])), _attrs = encode_pubsub_subscriptions_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"subscriptions">>, _attrs, _els}. 'encode_pubsub_subscriptions_$subscriptions'([], __TopXMLNS, _acc) -> _acc; 'encode_pubsub_subscriptions_$subscriptions'([Subscriptions | _els], __TopXMLNS, _acc) -> 'encode_pubsub_subscriptions_$subscriptions'(_els, __TopXMLNS, [encode_pubsub_subscription(Subscriptions, __TopXMLNS) | _acc]). decode_pubsub_subscriptions_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_subscriptions_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_subscriptions_attr_node(<<>>, _acc) -> _acc; encode_pubsub_subscriptions_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_event(__TopXMLNS, __Opts, {xmlel, <<"event">>, _attrs, _els}) -> {Items, Create, Delete, Purge, Configuration, Subscription} = decode_pubsub_event_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined, undefined, undefined), {ps_event, Items, Purge, Subscription, Delete, Create, Configuration}. decode_pubsub_event_els(__TopXMLNS, __Opts, [], Items, Create, Delete, Purge, Configuration, Subscription) -> {Items, Create, Delete, Purge, Configuration, Subscription}; decode_pubsub_event_els(__TopXMLNS, __Opts, [{xmlel, <<"items">>, _attrs, _} = _el | _els], Items, Create, Delete, Purge, Configuration, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, decode_pubsub_items(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Create, Delete, Purge, Configuration, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, decode_pubsub_items(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Create, Delete, Purge, Configuration, Subscription); _ -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, Subscription) end; decode_pubsub_event_els(__TopXMLNS, __Opts, [{xmlel, <<"subscription">>, _attrs, _} = _el | _els], Items, Create, Delete, Purge, Configuration, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el)); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el)); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, decode_pubsub_subscription(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el)); _ -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, Subscription) end; decode_pubsub_event_els(__TopXMLNS, __Opts, [{xmlel, <<"purge">>, _attrs, _} = _el | _els], Items, Create, Delete, Purge, Configuration, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Configuration, Subscription); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Configuration, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, decode_pubsub_purge(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Configuration, Subscription); _ -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, Subscription) end; decode_pubsub_event_els(__TopXMLNS, __Opts, [{xmlel, <<"delete">>, _attrs, _} = _el | _els], Items, Create, Delete, Purge, Configuration, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Purge, Configuration, Subscription); <<"http://jabber.org/protocol/pubsub#owner">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#owner">>, __Opts, _el), Purge, Configuration, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, decode_pubsub_delete(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Purge, Configuration, Subscription); _ -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, Subscription) end; decode_pubsub_event_els(__TopXMLNS, __Opts, [{xmlel, <<"create">>, _attrs, _} = _el | _els], Items, Create, Delete, Purge, Configuration, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, decode_pubsub_create(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el), Delete, Purge, Configuration, Subscription); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, decode_pubsub_create(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Delete, Purge, Configuration, Subscription); _ -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, Subscription) end; decode_pubsub_event_els(__TopXMLNS, __Opts, [{xmlel, <<"configuration">>, _attrs, _} = _el | _els], Items, Create, Delete, Purge, Configuration, Subscription) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, decode_pubsub_event_configuration(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el), Subscription); _ -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, Subscription) end; decode_pubsub_event_els(__TopXMLNS, __Opts, [_ | _els], Items, Create, Delete, Purge, Configuration, Subscription) -> decode_pubsub_event_els(__TopXMLNS, __Opts, _els, Items, Create, Delete, Purge, Configuration, Subscription). encode_pubsub_event({ps_event, Items, Purge, Subscription, Delete, Create, Configuration}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#event">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_event_$items'(Items, __NewTopXMLNS, 'encode_pubsub_event_$create'(Create, __NewTopXMLNS, 'encode_pubsub_event_$delete'(Delete, __NewTopXMLNS, 'encode_pubsub_event_$purge'(Purge, __NewTopXMLNS, 'encode_pubsub_event_$configuration'(Configuration, __NewTopXMLNS, 'encode_pubsub_event_$subscription'(Subscription, __NewTopXMLNS, []))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"event">>, _attrs, _els}. 'encode_pubsub_event_$items'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_event_$items'(Items, __TopXMLNS, _acc) -> [encode_pubsub_items(Items, __TopXMLNS) | _acc]. 'encode_pubsub_event_$create'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_event_$create'(Create, __TopXMLNS, _acc) -> [encode_pubsub_create(Create, __TopXMLNS) | _acc]. 'encode_pubsub_event_$delete'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_event_$delete'(Delete, __TopXMLNS, _acc) -> [encode_pubsub_delete(Delete, __TopXMLNS) | _acc]. 'encode_pubsub_event_$purge'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_event_$purge'(Purge, __TopXMLNS, _acc) -> [encode_pubsub_purge(Purge, __TopXMLNS) | _acc]. 'encode_pubsub_event_$configuration'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_event_$configuration'(Configuration, __TopXMLNS, _acc) -> [encode_pubsub_event_configuration(Configuration, __TopXMLNS) | _acc]. 'encode_pubsub_event_$subscription'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_event_$subscription'(Subscription, __TopXMLNS, _acc) -> [encode_pubsub_subscription(Subscription, __TopXMLNS) | _acc]. decode_pubsub_items(__TopXMLNS, __Opts, {xmlel, <<"items">>, _attrs, _els}) -> {Items, Retract} = decode_pubsub_items_els(__TopXMLNS, __Opts, _els, [], undefined), {Xmlns, Max_items, Node, Subid} = decode_pubsub_items_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {ps_items, Xmlns, Node, Items, Max_items, Subid, Retract}. decode_pubsub_items_els(__TopXMLNS, __Opts, [], Items, Retract) -> {lists:reverse(Items), Retract}; decode_pubsub_items_els(__TopXMLNS, __Opts, [{xmlel, <<"retract">>, _attrs, _} = _el | _els], Items, Retract) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_items_els(__TopXMLNS, __Opts, _els, Items, decode_pubsub_event_retract(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el)); _ -> decode_pubsub_items_els(__TopXMLNS, __Opts, _els, Items, Retract) end; decode_pubsub_items_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items, Retract) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/pubsub">> -> decode_pubsub_items_els(__TopXMLNS, __Opts, _els, [decode_pubsub_item(<<"http://jabber.org/protocol/pubsub">>, __Opts, _el) | Items], Retract); <<"http://jabber.org/protocol/pubsub#event">> -> decode_pubsub_items_els(__TopXMLNS, __Opts, _els, [decode_pubsub_item(<<"http://jabber.org/protocol/pubsub#event">>, __Opts, _el) | Items], Retract); _ -> decode_pubsub_items_els(__TopXMLNS, __Opts, _els, Items, Retract) end; decode_pubsub_items_els(__TopXMLNS, __Opts, [_ | _els], Items, Retract) -> decode_pubsub_items_els(__TopXMLNS, __Opts, _els, Items, Retract). decode_pubsub_items_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns, Max_items, Node, Subid) -> decode_pubsub_items_attrs(__TopXMLNS, _attrs, _val, Max_items, Node, Subid); decode_pubsub_items_attrs(__TopXMLNS, [{<<"max_items">>, _val} | _attrs], Xmlns, _Max_items, Node, Subid) -> decode_pubsub_items_attrs(__TopXMLNS, _attrs, Xmlns, _val, Node, Subid); decode_pubsub_items_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Xmlns, Max_items, _Node, Subid) -> decode_pubsub_items_attrs(__TopXMLNS, _attrs, Xmlns, Max_items, _val, Subid); decode_pubsub_items_attrs(__TopXMLNS, [{<<"subid">>, _val} | _attrs], Xmlns, Max_items, Node, _Subid) -> decode_pubsub_items_attrs(__TopXMLNS, _attrs, Xmlns, Max_items, Node, _val); decode_pubsub_items_attrs(__TopXMLNS, [_ | _attrs], Xmlns, Max_items, Node, Subid) -> decode_pubsub_items_attrs(__TopXMLNS, _attrs, Xmlns, Max_items, Node, Subid); decode_pubsub_items_attrs(__TopXMLNS, [], Xmlns, Max_items, Node, Subid) -> {decode_pubsub_items_attr_xmlns(__TopXMLNS, Xmlns), decode_pubsub_items_attr_max_items(__TopXMLNS, Max_items), decode_pubsub_items_attr_node(__TopXMLNS, Node), decode_pubsub_items_attr_subid(__TopXMLNS, Subid)}. encode_pubsub_items({ps_items, Xmlns, Node, Items, Max_items, Subid, Retract}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#event">>], __TopXMLNS), _els = lists:reverse('encode_pubsub_items_$items'(Items, __NewTopXMLNS, 'encode_pubsub_items_$retract'(Retract, __NewTopXMLNS, []))), _attrs = encode_pubsub_items_attr_subid(Subid, encode_pubsub_items_attr_node(Node, encode_pubsub_items_attr_max_items(Max_items, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"items">>, _attrs, _els}. 'encode_pubsub_items_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_pubsub_items_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_pubsub_items_$items'(_els, __TopXMLNS, [encode_pubsub_item(Items, __TopXMLNS) | _acc]). 'encode_pubsub_items_$retract'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_items_$retract'(Retract, __TopXMLNS, _acc) -> [encode_pubsub_event_retract(Retract, __TopXMLNS) | _acc]. decode_pubsub_items_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_pubsub_items_attr_xmlns(__TopXMLNS, _val) -> _val. decode_pubsub_items_attr_max_items(__TopXMLNS, undefined) -> undefined; decode_pubsub_items_attr_max_items(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"max_items">>, <<"items">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_items_attr_max_items(undefined, _acc) -> _acc; encode_pubsub_items_attr_max_items(_val, _acc) -> [{<<"max_items">>, enc_int(_val)} | _acc]. decode_pubsub_items_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"items">>, __TopXMLNS}}); decode_pubsub_items_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_items_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_items_attr_subid(__TopXMLNS, undefined) -> <<>>; decode_pubsub_items_attr_subid(__TopXMLNS, _val) -> _val. encode_pubsub_items_attr_subid(<<>>, _acc) -> _acc; encode_pubsub_items_attr_subid(_val, _acc) -> [{<<"subid">>, _val} | _acc]. decode_pubsub_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> __Els = decode_pubsub_item_els(__TopXMLNS, __Opts, _els, []), {Id, Xmlns, Node, Publisher} = decode_pubsub_item_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {ps_item, Xmlns, Id, __Els, Node, Publisher}. decode_pubsub_item_els(__TopXMLNS, __Opts, [], __Els) -> lists:reverse(__Els); decode_pubsub_item_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], __Els) -> decode_pubsub_item_els(__TopXMLNS, __Opts, _els, [_el | __Els]); decode_pubsub_item_els(__TopXMLNS, __Opts, [_ | _els], __Els) -> decode_pubsub_item_els(__TopXMLNS, __Opts, _els, __Els). decode_pubsub_item_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, Xmlns, Node, Publisher) -> decode_pubsub_item_attrs(__TopXMLNS, _attrs, _val, Xmlns, Node, Publisher); decode_pubsub_item_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Id, _Xmlns, Node, Publisher) -> decode_pubsub_item_attrs(__TopXMLNS, _attrs, Id, _val, Node, Publisher); decode_pubsub_item_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Id, Xmlns, _Node, Publisher) -> decode_pubsub_item_attrs(__TopXMLNS, _attrs, Id, Xmlns, _val, Publisher); decode_pubsub_item_attrs(__TopXMLNS, [{<<"publisher">>, _val} | _attrs], Id, Xmlns, Node, _Publisher) -> decode_pubsub_item_attrs(__TopXMLNS, _attrs, Id, Xmlns, Node, _val); decode_pubsub_item_attrs(__TopXMLNS, [_ | _attrs], Id, Xmlns, Node, Publisher) -> decode_pubsub_item_attrs(__TopXMLNS, _attrs, Id, Xmlns, Node, Publisher); decode_pubsub_item_attrs(__TopXMLNS, [], Id, Xmlns, Node, Publisher) -> {decode_pubsub_item_attr_id(__TopXMLNS, Id), decode_pubsub_item_attr_xmlns(__TopXMLNS, Xmlns), decode_pubsub_item_attr_node(__TopXMLNS, Node), decode_pubsub_item_attr_publisher(__TopXMLNS, Publisher)}. encode_pubsub_item({ps_item, Xmlns, Id, __Els, Node, Publisher}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#event">>], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els], _attrs = encode_pubsub_item_attr_publisher(Publisher, encode_pubsub_item_attr_node(Node, encode_pubsub_item_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"item">>, _attrs, _els}. decode_pubsub_item_attr_id(__TopXMLNS, undefined) -> <<>>; decode_pubsub_item_attr_id(__TopXMLNS, _val) -> _val. encode_pubsub_item_attr_id(<<>>, _acc) -> _acc; encode_pubsub_item_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_pubsub_item_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_pubsub_item_attr_xmlns(__TopXMLNS, _val) -> _val. decode_pubsub_item_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_item_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_item_attr_node(<<>>, _acc) -> _acc; encode_pubsub_item_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_item_attr_publisher(__TopXMLNS, undefined) -> <<>>; decode_pubsub_item_attr_publisher(__TopXMLNS, _val) -> _val. encode_pubsub_item_attr_publisher(<<>>, _acc) -> _acc; encode_pubsub_item_attr_publisher(_val, _acc) -> [{<<"publisher">>, _val} | _acc]. decode_pubsub_event_retract(__TopXMLNS, __Opts, {xmlel, <<"retract">>, _attrs, _els}) -> Id = decode_pubsub_event_retract_attrs(__TopXMLNS, _attrs, undefined), Id. decode_pubsub_event_retract_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id) -> decode_pubsub_event_retract_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_event_retract_attrs(__TopXMLNS, [_ | _attrs], Id) -> decode_pubsub_event_retract_attrs(__TopXMLNS, _attrs, Id); decode_pubsub_event_retract_attrs(__TopXMLNS, [], Id) -> decode_pubsub_event_retract_attr_id(__TopXMLNS, Id). encode_pubsub_event_retract(Id, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#event">>, [], __TopXMLNS), _els = [], _attrs = encode_pubsub_event_retract_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"retract">>, _attrs, _els}. decode_pubsub_event_retract_attr_id(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"id">>, <<"retract">>, __TopXMLNS}}); decode_pubsub_event_retract_attr_id(__TopXMLNS, _val) -> _val. encode_pubsub_event_retract_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_pubsub_event_configuration(__TopXMLNS, __Opts, {xmlel, <<"configuration">>, _attrs, _els}) -> Xdata = decode_pubsub_event_configuration_els(__TopXMLNS, __Opts, _els, undefined), Node = decode_pubsub_event_configuration_attrs(__TopXMLNS, _attrs, undefined), {Node, Xdata}. decode_pubsub_event_configuration_els(__TopXMLNS, __Opts, [], Xdata) -> Xdata; decode_pubsub_event_configuration_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_pubsub_event_configuration_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el)); _ -> decode_pubsub_event_configuration_els(__TopXMLNS, __Opts, _els, Xdata) end; decode_pubsub_event_configuration_els(__TopXMLNS, __Opts, [_ | _els], Xdata) -> decode_pubsub_event_configuration_els(__TopXMLNS, __Opts, _els, Xdata). decode_pubsub_event_configuration_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_pubsub_event_configuration_attrs(__TopXMLNS, _attrs, _val); decode_pubsub_event_configuration_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_pubsub_event_configuration_attrs(__TopXMLNS, _attrs, Node); decode_pubsub_event_configuration_attrs(__TopXMLNS, [], Node) -> decode_pubsub_event_configuration_attr_node(__TopXMLNS, Node). encode_pubsub_event_configuration({Node, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/pubsub#event">>, [], __TopXMLNS), _els = lists:reverse('encode_pubsub_event_configuration_$xdata'(Xdata, __NewTopXMLNS, [])), _attrs = encode_pubsub_event_configuration_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"configuration">>, _attrs, _els}. 'encode_pubsub_event_configuration_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_pubsub_event_configuration_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. decode_pubsub_event_configuration_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"configuration">>, __TopXMLNS}}); decode_pubsub_event_configuration_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_event_configuration_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_owner_affiliation(__TopXMLNS, __Opts, {xmlel, <<"affiliation">>, _attrs, _els}) -> {Jid, Xmlns, Type} = decode_pubsub_owner_affiliation_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {ps_affiliation, Xmlns, <<>>, Type, Jid}. decode_pubsub_owner_affiliation_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Xmlns, Type) -> decode_pubsub_owner_affiliation_attrs(__TopXMLNS, _attrs, _val, Xmlns, Type); decode_pubsub_owner_affiliation_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Jid, _Xmlns, Type) -> decode_pubsub_owner_affiliation_attrs(__TopXMLNS, _attrs, Jid, _val, Type); decode_pubsub_owner_affiliation_attrs(__TopXMLNS, [{<<"affiliation">>, _val} | _attrs], Jid, Xmlns, _Type) -> decode_pubsub_owner_affiliation_attrs(__TopXMLNS, _attrs, Jid, Xmlns, _val); decode_pubsub_owner_affiliation_attrs(__TopXMLNS, [_ | _attrs], Jid, Xmlns, Type) -> decode_pubsub_owner_affiliation_attrs(__TopXMLNS, _attrs, Jid, Xmlns, Type); decode_pubsub_owner_affiliation_attrs(__TopXMLNS, [], Jid, Xmlns, Type) -> {decode_pubsub_owner_affiliation_attr_jid(__TopXMLNS, Jid), decode_pubsub_owner_affiliation_attr_xmlns(__TopXMLNS, Xmlns), decode_pubsub_owner_affiliation_attr_affiliation(__TopXMLNS, Type)}. encode_pubsub_owner_affiliation({ps_affiliation, Xmlns, _, Type, Jid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"http://jabber.org/protocol/pubsub#owner">>], __TopXMLNS), _els = [], _attrs = encode_pubsub_owner_affiliation_attr_affiliation(Type, encode_pubsub_owner_affiliation_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"affiliation">>, _attrs, _els}. decode_pubsub_owner_affiliation_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"affiliation">>, __TopXMLNS}}); decode_pubsub_owner_affiliation_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"affiliation">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_owner_affiliation_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_pubsub_owner_affiliation_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_pubsub_owner_affiliation_attr_xmlns(__TopXMLNS, _val) -> _val. decode_pubsub_owner_affiliation_attr_affiliation(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"affiliation">>, <<"affiliation">>, __TopXMLNS}}); decode_pubsub_owner_affiliation_attr_affiliation(__TopXMLNS, _val) -> case catch dec_ps_aff(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"affiliation">>, <<"affiliation">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_owner_affiliation_attr_affiliation(_val, _acc) -> [{<<"affiliation">>, enc_ps_aff(_val)} | _acc]. decode_pubsub_affiliation(__TopXMLNS, __Opts, {xmlel, <<"affiliation">>, _attrs, _els}) -> {Node, Xmlns, Type} = decode_pubsub_affiliation_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {ps_affiliation, Xmlns, Node, Type, undefined}. decode_pubsub_affiliation_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node, Xmlns, Type) -> decode_pubsub_affiliation_attrs(__TopXMLNS, _attrs, _val, Xmlns, Type); decode_pubsub_affiliation_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Node, _Xmlns, Type) -> decode_pubsub_affiliation_attrs(__TopXMLNS, _attrs, Node, _val, Type); decode_pubsub_affiliation_attrs(__TopXMLNS, [{<<"affiliation">>, _val} | _attrs], Node, Xmlns, _Type) -> decode_pubsub_affiliation_attrs(__TopXMLNS, _attrs, Node, Xmlns, _val); decode_pubsub_affiliation_attrs(__TopXMLNS, [_ | _attrs], Node, Xmlns, Type) -> decode_pubsub_affiliation_attrs(__TopXMLNS, _attrs, Node, Xmlns, Type); decode_pubsub_affiliation_attrs(__TopXMLNS, [], Node, Xmlns, Type) -> {decode_pubsub_affiliation_attr_node(__TopXMLNS, Node), decode_pubsub_affiliation_attr_xmlns(__TopXMLNS, Xmlns), decode_pubsub_affiliation_attr_affiliation(__TopXMLNS, Type)}. encode_pubsub_affiliation({ps_affiliation, Xmlns, Node, Type, _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"http://jabber.org/protocol/pubsub">>], __TopXMLNS), _els = [], _attrs = encode_pubsub_affiliation_attr_affiliation(Type, encode_pubsub_affiliation_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"affiliation">>, _attrs, _els}. decode_pubsub_affiliation_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"affiliation">>, __TopXMLNS}}); decode_pubsub_affiliation_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_affiliation_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_affiliation_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_pubsub_affiliation_attr_xmlns(__TopXMLNS, _val) -> _val. decode_pubsub_affiliation_attr_affiliation(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"affiliation">>, <<"affiliation">>, __TopXMLNS}}); decode_pubsub_affiliation_attr_affiliation(__TopXMLNS, _val) -> case catch dec_ps_aff(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"affiliation">>, <<"affiliation">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_affiliation_attr_affiliation(_val, _acc) -> [{<<"affiliation">>, enc_ps_aff(_val)} | _acc]. decode_pubsub_subscription(__TopXMLNS, __Opts, {xmlel, <<"subscription">>, _attrs, _els}) -> {Xmlns, Jid, Node, Subid, Type, Expiry} = decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined, undefined), {ps_subscription, Xmlns, Jid, Type, Node, Subid, Expiry}. decode_pubsub_subscription_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns, Jid, Node, Subid, Type, Expiry) -> decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, _val, Jid, Node, Subid, Type, Expiry); decode_pubsub_subscription_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Xmlns, _Jid, Node, Subid, Type, Expiry) -> decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, Xmlns, _val, Node, Subid, Type, Expiry); decode_pubsub_subscription_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], Xmlns, Jid, _Node, Subid, Type, Expiry) -> decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, Xmlns, Jid, _val, Subid, Type, Expiry); decode_pubsub_subscription_attrs(__TopXMLNS, [{<<"subid">>, _val} | _attrs], Xmlns, Jid, Node, _Subid, Type, Expiry) -> decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, Xmlns, Jid, Node, _val, Type, Expiry); decode_pubsub_subscription_attrs(__TopXMLNS, [{<<"subscription">>, _val} | _attrs], Xmlns, Jid, Node, Subid, _Type, Expiry) -> decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, Xmlns, Jid, Node, Subid, _val, Expiry); decode_pubsub_subscription_attrs(__TopXMLNS, [{<<"expiry">>, _val} | _attrs], Xmlns, Jid, Node, Subid, Type, _Expiry) -> decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, Xmlns, Jid, Node, Subid, Type, _val); decode_pubsub_subscription_attrs(__TopXMLNS, [_ | _attrs], Xmlns, Jid, Node, Subid, Type, Expiry) -> decode_pubsub_subscription_attrs(__TopXMLNS, _attrs, Xmlns, Jid, Node, Subid, Type, Expiry); decode_pubsub_subscription_attrs(__TopXMLNS, [], Xmlns, Jid, Node, Subid, Type, Expiry) -> {decode_pubsub_subscription_attr_xmlns(__TopXMLNS, Xmlns), decode_pubsub_subscription_attr_jid(__TopXMLNS, Jid), decode_pubsub_subscription_attr_node(__TopXMLNS, Node), decode_pubsub_subscription_attr_subid(__TopXMLNS, Subid), decode_pubsub_subscription_attr_subscription(__TopXMLNS, Type), decode_pubsub_subscription_attr_expiry(__TopXMLNS, Expiry)}. encode_pubsub_subscription({ps_subscription, Xmlns, Jid, Type, Node, Subid, Expiry}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"http://jabber.org/protocol/pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>, <<"http://jabber.org/protocol/pubsub#event">>], __TopXMLNS), _els = [], _attrs = encode_pubsub_subscription_attr_expiry(Expiry, encode_pubsub_subscription_attr_subscription(Type, encode_pubsub_subscription_attr_subid(Subid, encode_pubsub_subscription_attr_node(Node, encode_pubsub_subscription_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"subscription">>, _attrs, _els}. decode_pubsub_subscription_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_pubsub_subscription_attr_xmlns(__TopXMLNS, _val) -> _val. decode_pubsub_subscription_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"subscription">>, __TopXMLNS}}); decode_pubsub_subscription_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"subscription">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_subscription_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_pubsub_subscription_attr_node(__TopXMLNS, undefined) -> <<>>; decode_pubsub_subscription_attr_node(__TopXMLNS, _val) -> _val. encode_pubsub_subscription_attr_node(<<>>, _acc) -> _acc; encode_pubsub_subscription_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_pubsub_subscription_attr_subid(__TopXMLNS, undefined) -> <<>>; decode_pubsub_subscription_attr_subid(__TopXMLNS, _val) -> _val. encode_pubsub_subscription_attr_subid(<<>>, _acc) -> _acc; encode_pubsub_subscription_attr_subid(_val, _acc) -> [{<<"subid">>, _val} | _acc]. decode_pubsub_subscription_attr_subscription(__TopXMLNS, undefined) -> undefined; decode_pubsub_subscription_attr_subscription(__TopXMLNS, _val) -> case catch dec_enum(_val, [none, pending, subscribed, unconfigured]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"subscription">>, <<"subscription">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_subscription_attr_subscription(undefined, _acc) -> _acc; encode_pubsub_subscription_attr_subscription(_val, _acc) -> [{<<"subscription">>, enc_enum(_val)} | _acc]. decode_pubsub_subscription_attr_expiry(__TopXMLNS, undefined) -> undefined; decode_pubsub_subscription_attr_expiry(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"expiry">>, <<"subscription">>, __TopXMLNS}}); _res -> _res end. encode_pubsub_subscription_attr_expiry(undefined, _acc) -> _acc; encode_pubsub_subscription_attr_expiry(_val, _acc) -> [{<<"expiry">>, enc_utc(_val)} | _acc]. xmpp-1.4.4/src/xep0355.erl0000644000232200023220000002742013610066730015465 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0355). -compile(export_all). do_decode(<<"query">>, <<"urn:xmpp:delegation:1">>, El, Opts) -> decode_delegation_query(<<"urn:xmpp:delegation:1">>, Opts, El); do_decode(<<"delegate">>, <<"urn:xmpp:delegation:1">>, El, Opts) -> decode_delegate(<<"urn:xmpp:delegation:1">>, Opts, El); do_decode(<<"delegation">>, <<"urn:xmpp:delegation:1">>, El, Opts) -> decode_delegation(<<"urn:xmpp:delegation:1">>, Opts, El); do_decode(<<"delegated">>, <<"urn:xmpp:delegation:1">>, El, Opts) -> decode_delegated(<<"urn:xmpp:delegation:1">>, Opts, El); do_decode(<<"attribute">>, <<"urn:xmpp:delegation:1">>, El, Opts) -> decode_delegated_attribute(<<"urn:xmpp:delegation:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"urn:xmpp:delegation:1">>}, {<<"delegate">>, <<"urn:xmpp:delegation:1">>}, {<<"delegation">>, <<"urn:xmpp:delegation:1">>}, {<<"delegated">>, <<"urn:xmpp:delegation:1">>}, {<<"attribute">>, <<"urn:xmpp:delegation:1">>}]. do_encode({delegated, _, _} = Delegated, TopXMLNS) -> encode_delegated(Delegated, TopXMLNS); do_encode({delegation, _, _} = Delegation, TopXMLNS) -> encode_delegation(Delegation, TopXMLNS); do_encode({delegation_query, _, _} = Query, TopXMLNS) -> encode_delegation_query(Query, TopXMLNS). do_get_name({delegated, _, _}) -> <<"delegated">>; do_get_name({delegation, _, _}) -> <<"delegation">>; do_get_name({delegation_query, _, _}) -> <<"query">>. do_get_ns({delegated, _, _}) -> <<"urn:xmpp:delegation:1">>; do_get_ns({delegation, _, _}) -> <<"urn:xmpp:delegation:1">>; do_get_ns({delegation_query, _, _}) -> <<"urn:xmpp:delegation:1">>. pp(delegated, 2) -> [ns, attrs]; pp(delegation, 2) -> [delegated, forwarded]; pp(delegation_query, 2) -> [to, delegate]; pp(_, _) -> no. records() -> [{delegated, 2}, {delegation, 2}, {delegation_query, 2}]. decode_delegation_query(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> Delegate = decode_delegation_query_els(__TopXMLNS, __Opts, _els, []), To = decode_delegation_query_attrs(__TopXMLNS, _attrs, undefined), {delegation_query, To, Delegate}. decode_delegation_query_els(__TopXMLNS, __Opts, [], Delegate) -> lists:reverse(Delegate); decode_delegation_query_els(__TopXMLNS, __Opts, [{xmlel, <<"delegate">>, _attrs, _} = _el | _els], Delegate) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:delegation:1">> -> decode_delegation_query_els(__TopXMLNS, __Opts, _els, [decode_delegate(<<"urn:xmpp:delegation:1">>, __Opts, _el) | Delegate]); _ -> decode_delegation_query_els(__TopXMLNS, __Opts, _els, Delegate) end; decode_delegation_query_els(__TopXMLNS, __Opts, [_ | _els], Delegate) -> decode_delegation_query_els(__TopXMLNS, __Opts, _els, Delegate). decode_delegation_query_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], _To) -> decode_delegation_query_attrs(__TopXMLNS, _attrs, _val); decode_delegation_query_attrs(__TopXMLNS, [_ | _attrs], To) -> decode_delegation_query_attrs(__TopXMLNS, _attrs, To); decode_delegation_query_attrs(__TopXMLNS, [], To) -> decode_delegation_query_attr_to(__TopXMLNS, To). encode_delegation_query({delegation_query, To, Delegate}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:delegation:1">>, [], __TopXMLNS), _els = lists:reverse('encode_delegation_query_$delegate'(Delegate, __NewTopXMLNS, [])), _attrs = encode_delegation_query_attr_to(To, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"query">>, _attrs, _els}. 'encode_delegation_query_$delegate'([], __TopXMLNS, _acc) -> _acc; 'encode_delegation_query_$delegate'([Delegate | _els], __TopXMLNS, _acc) -> 'encode_delegation_query_$delegate'(_els, __TopXMLNS, [encode_delegate(Delegate, __TopXMLNS) | _acc]). decode_delegation_query_attr_to(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"to">>, <<"query">>, __TopXMLNS}}); decode_delegation_query_attr_to(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"query">>, __TopXMLNS}}); _res -> _res end. encode_delegation_query_attr_to(_val, _acc) -> [{<<"to">>, jid:encode(_val)} | _acc]. decode_delegate(__TopXMLNS, __Opts, {xmlel, <<"delegate">>, _attrs, _els}) -> Namespace = decode_delegate_attrs(__TopXMLNS, _attrs, undefined), Namespace. decode_delegate_attrs(__TopXMLNS, [{<<"namespace">>, _val} | _attrs], _Namespace) -> decode_delegate_attrs(__TopXMLNS, _attrs, _val); decode_delegate_attrs(__TopXMLNS, [_ | _attrs], Namespace) -> decode_delegate_attrs(__TopXMLNS, _attrs, Namespace); decode_delegate_attrs(__TopXMLNS, [], Namespace) -> decode_delegate_attr_namespace(__TopXMLNS, Namespace). encode_delegate(Namespace, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:delegation:1">>, [], __TopXMLNS), _els = [], _attrs = encode_delegate_attr_namespace(Namespace, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"delegate">>, _attrs, _els}. decode_delegate_attr_namespace(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"namespace">>, <<"delegate">>, __TopXMLNS}}); decode_delegate_attr_namespace(__TopXMLNS, _val) -> _val. encode_delegate_attr_namespace(_val, _acc) -> [{<<"namespace">>, _val} | _acc]. decode_delegation(__TopXMLNS, __Opts, {xmlel, <<"delegation">>, _attrs, _els}) -> {Forwarded, Delegated} = decode_delegation_els(__TopXMLNS, __Opts, _els, undefined, []), {delegation, Delegated, Forwarded}. decode_delegation_els(__TopXMLNS, __Opts, [], Forwarded, Delegated) -> {Forwarded, lists:reverse(Delegated)}; decode_delegation_els(__TopXMLNS, __Opts, [{xmlel, <<"delegated">>, _attrs, _} = _el | _els], Forwarded, Delegated) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:delegation:1">> -> decode_delegation_els(__TopXMLNS, __Opts, _els, Forwarded, [decode_delegated(<<"urn:xmpp:delegation:1">>, __Opts, _el) | Delegated]); _ -> decode_delegation_els(__TopXMLNS, __Opts, _els, Forwarded, Delegated) end; decode_delegation_els(__TopXMLNS, __Opts, [{xmlel, <<"forwarded">>, _attrs, _} = _el | _els], Forwarded, Delegated) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:forward:0">> -> decode_delegation_els(__TopXMLNS, __Opts, _els, xep0297:decode_forwarded(<<"urn:xmpp:forward:0">>, __Opts, _el), Delegated); _ -> decode_delegation_els(__TopXMLNS, __Opts, _els, Forwarded, Delegated) end; decode_delegation_els(__TopXMLNS, __Opts, [_ | _els], Forwarded, Delegated) -> decode_delegation_els(__TopXMLNS, __Opts, _els, Forwarded, Delegated). encode_delegation({delegation, Delegated, Forwarded}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:delegation:1">>, [], __TopXMLNS), _els = lists:reverse('encode_delegation_$forwarded'(Forwarded, __NewTopXMLNS, 'encode_delegation_$delegated'(Delegated, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"delegation">>, _attrs, _els}. 'encode_delegation_$forwarded'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_delegation_$forwarded'(Forwarded, __TopXMLNS, _acc) -> [xep0297:encode_forwarded(Forwarded, __TopXMLNS) | _acc]. 'encode_delegation_$delegated'([], __TopXMLNS, _acc) -> _acc; 'encode_delegation_$delegated'([Delegated | _els], __TopXMLNS, _acc) -> 'encode_delegation_$delegated'(_els, __TopXMLNS, [encode_delegated(Delegated, __TopXMLNS) | _acc]). decode_delegated(__TopXMLNS, __Opts, {xmlel, <<"delegated">>, _attrs, _els}) -> Attrs = decode_delegated_els(__TopXMLNS, __Opts, _els, []), Ns = decode_delegated_attrs(__TopXMLNS, _attrs, undefined), {delegated, Ns, Attrs}. decode_delegated_els(__TopXMLNS, __Opts, [], Attrs) -> lists:reverse(Attrs); decode_delegated_els(__TopXMLNS, __Opts, [{xmlel, <<"attribute">>, _attrs, _} = _el | _els], Attrs) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:delegation:1">> -> decode_delegated_els(__TopXMLNS, __Opts, _els, [decode_delegated_attribute(<<"urn:xmpp:delegation:1">>, __Opts, _el) | Attrs]); _ -> decode_delegated_els(__TopXMLNS, __Opts, _els, Attrs) end; decode_delegated_els(__TopXMLNS, __Opts, [_ | _els], Attrs) -> decode_delegated_els(__TopXMLNS, __Opts, _els, Attrs). decode_delegated_attrs(__TopXMLNS, [{<<"namespace">>, _val} | _attrs], _Ns) -> decode_delegated_attrs(__TopXMLNS, _attrs, _val); decode_delegated_attrs(__TopXMLNS, [_ | _attrs], Ns) -> decode_delegated_attrs(__TopXMLNS, _attrs, Ns); decode_delegated_attrs(__TopXMLNS, [], Ns) -> decode_delegated_attr_namespace(__TopXMLNS, Ns). encode_delegated({delegated, Ns, Attrs}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:delegation:1">>, [], __TopXMLNS), _els = lists:reverse('encode_delegated_$attrs'(Attrs, __NewTopXMLNS, [])), _attrs = encode_delegated_attr_namespace(Ns, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"delegated">>, _attrs, _els}. 'encode_delegated_$attrs'([], __TopXMLNS, _acc) -> _acc; 'encode_delegated_$attrs'([Attrs | _els], __TopXMLNS, _acc) -> 'encode_delegated_$attrs'(_els, __TopXMLNS, [encode_delegated_attribute(Attrs, __TopXMLNS) | _acc]). decode_delegated_attr_namespace(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"namespace">>, <<"delegated">>, __TopXMLNS}}); decode_delegated_attr_namespace(__TopXMLNS, _val) -> _val. encode_delegated_attr_namespace(_val, _acc) -> [{<<"namespace">>, _val} | _acc]. decode_delegated_attribute(__TopXMLNS, __Opts, {xmlel, <<"attribute">>, _attrs, _els}) -> Name = decode_delegated_attribute_attrs(__TopXMLNS, _attrs, undefined), Name. decode_delegated_attribute_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name) -> decode_delegated_attribute_attrs(__TopXMLNS, _attrs, _val); decode_delegated_attribute_attrs(__TopXMLNS, [_ | _attrs], Name) -> decode_delegated_attribute_attrs(__TopXMLNS, _attrs, Name); decode_delegated_attribute_attrs(__TopXMLNS, [], Name) -> decode_delegated_attribute_attr_name(__TopXMLNS, Name). encode_delegated_attribute(Name, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:delegation:1">>, [], __TopXMLNS), _els = [], _attrs = encode_delegated_attribute_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"attribute">>, _attrs, _els}. decode_delegated_attribute_attr_name(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"name">>, <<"attribute">>, __TopXMLNS}}); decode_delegated_attribute_attr_name(__TopXMLNS, _val) -> _val. encode_delegated_attribute_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. xmpp-1.4.4/src/pubsub_subscribe_authorization.erl0000644000232200023220000002576413610066730022706 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_subscribe_authorization.xdata %% Form type: http://jabber.org/protocol/pubsub#subscribe_authorization %% Document: XEP-0060 -module(pubsub_subscribe_authorization). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("pubsub_subscribe_authorization.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [allow | node | subscriber_jid | subid]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/pubsub#subscribe_a" "uthorization">>], [<<"pubsub#allow">>, <<"pubsub#node">>, <<"pubsub#subscriber_jid">>], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [<<"pubsub#allow">>, <<"pubsub#node">>, <<"pubsub#subscriber_jid">>], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, [allow, node, subscriber_jid]). encode(Cfg, Lang) -> encode(Cfg, Lang, [allow, node, subscriber_jid]). encode(List, Lang, Required) -> Fs = [case Opt of {allow, Val} -> [encode_allow(Val, Lang, lists:member(allow, Required))]; {node, Val} -> [encode_node(Val, Lang, lists:member(node, Required))]; {subscriber_jid, Val} -> [encode_subscriber_jid(Val, Lang, lists:member(subscriber_jid, Required))]; {subid, Val} -> [encode_subid(Val, Lang, lists:member(subid, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/pubsub#subscribe_a" "uthorization">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"pubsub#allow">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#allow">>, Required), [{allow, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#allow">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#allow">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#allow">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#allow">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#allow">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#node">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#node">>, Required), [{node, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#node">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#node">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#node">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#node">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#node">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#subscriber_jid">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try jid:decode(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#subscriber_jid">>, Required), [{subscriber_jid, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#subscriber_jid">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#subscriber_jid">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#subscriber_jid">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#subscriber_jid">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#subscriber_jid">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#subid">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#subid">>, Required), [{subid, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#subid">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#subid">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#subid">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#subid">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#subid">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_allow(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#allow">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow this Jabber ID to subscribe to " "this pubsub node?"))}. -spec encode_node(binary(), binary(), boolean()) -> xdata_field(). encode_node(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#node">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Node ID"))}. -spec encode_subscriber_jid(jid:jid() | undefined, binary(), boolean()) -> xdata_field(). encode_subscriber_jid(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [jid:encode(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#subscriber_jid">>, values = Values, required = IsRequired, type = 'jid-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Subscriber Address"))}. -spec encode_subid(binary(), binary(), boolean()) -> xdata_field(). encode_subid(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#subid">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The subscription identifier associated " "with the subscription request"))}. xmpp-1.4.4/src/muc_roominfo.erl0000644000232200023220000006366413610066730017062 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_roominfo.xdata %% Form type: http://jabber.org/protocol/muc#roominfo %% Document: XEP-0045 -module(muc_roominfo). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("muc_roominfo.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [maxhistoryfetch | allowinvites | allowpm | contactjid | description | lang | ldapgroup | logs | roomname | occupants | subject | subjectmod | pubsub | changesubject]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/muc#roominfo">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {maxhistoryfetch, Val} -> [encode_maxhistoryfetch(Val, Lang, lists:member(maxhistoryfetch, Required))]; {allowinvites, Val} -> [encode_allowinvites(Val, Lang, lists:member(allowinvites, Required))]; {allowpm, Val} -> [encode_allowpm(Val, default, Lang, lists:member(allowpm, Required))]; {allowpm, Val, Opts} -> [encode_allowpm(Val, Opts, Lang, lists:member(allowpm, Required))]; {contactjid, Val} -> [encode_contactjid(Val, Lang, lists:member(contactjid, Required))]; {description, Val} -> [encode_description(Val, Lang, lists:member(description, Required))]; {lang, Val} -> [encode_lang(Val, Lang, lists:member(lang, Required))]; {ldapgroup, Val} -> [encode_ldapgroup(Val, Lang, lists:member(ldapgroup, Required))]; {logs, Val} -> [encode_logs(Val, Lang, lists:member(logs, Required))]; {roomname, Val} -> [encode_roomname(Val, Lang, lists:member(roomname, Required))]; {occupants, Val} -> [encode_occupants(Val, Lang, lists:member(occupants, Required))]; {subject, Val} -> [encode_subject(Val, Lang, lists:member(subject, Required))]; {subjectmod, Val} -> [encode_subjectmod(Val, Lang, lists:member(subjectmod, Required))]; {pubsub, Val} -> [encode_pubsub(Val, Lang, lists:member(pubsub, Required))]; {changesubject, Val} -> [encode_changesubject(Val, Lang, lists:member(changesubject, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/muc#roominfo">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"muc#maxhistoryfetch">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#maxhistoryfetch">>, Required), [{maxhistoryfetch, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#maxhistoryfetch">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#maxhistoryfetch">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#maxhistoryfetch">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#maxhistoryfetch">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#maxhistoryfetch">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_allowinvites">>, Required), [{allowinvites, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_allowinvites">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_allowinvites">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_allowinvites">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_allowpm">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [anyone, participants, moderators, none]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_allowpm">>, Required), [{allowpm, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_allowpm">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_allowpm">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_allowpm">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_allowpm">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_allowpm">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_contactjid">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"muc#roominfo_contactjid">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_contactjid">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_contactjid">>, Required), [{contactjid, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_contactjid">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_description">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_description">>, Required), [{description, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_description">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_description">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_description">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_description">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_description">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_lang">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try xmpp_lang:check(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_lang">>, Required), [{lang, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_lang">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_lang">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_lang">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_lang">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_lang">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_ldapgroup">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_ldapgroup">>, Required), [{ldapgroup, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_ldapgroup">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_ldapgroup">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_ldapgroup">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_ldapgroup">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_ldapgroup">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_logs">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_logs">>, Required), [{logs, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_logs">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_logs">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_logs">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_logs">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_logs">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomconfig_roomname">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomconfig_roomname">>, Required), [{roomname, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomconfig_roomname">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomconfig_roomname">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomconfig_roomname">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomconfig_roomname">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomconfig_roomname">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_occupants">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_occupants">>, Required), [{occupants, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_occupants">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_occupants">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_occupants">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_occupants">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_occupants">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_subject">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_subject">>, Required), [{subject, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_subject">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_subject">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_subject">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_subject">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_subject">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_subjectmod">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_subjectmod">>, Required), [{subjectmod, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_subjectmod">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_subjectmod">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_subjectmod">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_subjectmod">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_subjectmod">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_pubsub">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try xmpp_uri:check(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_pubsub">>, Required), [{pubsub, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_pubsub">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_pubsub">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_pubsub">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_pubsub">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_pubsub">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roominfo_changesubject">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roominfo_changesubject">>, Required), [{changesubject, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roominfo_changesubject">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roominfo_changesubject">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roominfo_changesubject">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roominfo_changesubject">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roominfo_changesubject">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_maxhistoryfetch(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_maxhistoryfetch(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"muc#maxhistoryfetch">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Maximum Number of History Messages Returned " "by Room"))}. -spec encode_allowinvites(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allowinvites(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_allowinvites">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Occupants are allowed to invite others"))}. -spec encode_allowpm(allowpm() | undefined, default | options(allowpm()), binary(), boolean()) -> xdata_field(). encode_allowpm(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone")), value = <<"anyone">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone with Voice")), value = <<"participants">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Moderators Only")), value = <<"moderators">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Nobody")), value = <<"none">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"muc#roomconfig_allowpm">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Roles that May Send Private Messages"))}. -spec encode_contactjid([jid:jid()], binary(), boolean()) -> xdata_field(). encode_contactjid(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"muc#roominfo_contactjid">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Contact Addresses (normally, room owner " "or owners)"))}. -spec encode_description(binary(), binary(), boolean()) -> xdata_field(). encode_description(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roominfo_description">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Room description"))}. -spec encode_lang(binary() | undefined, binary(), boolean()) -> xdata_field(). encode_lang(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roominfo_lang">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Natural Language for Room Discussions"))}. -spec encode_ldapgroup(binary(), binary(), boolean()) -> xdata_field(). encode_ldapgroup(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roominfo_ldapgroup">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("An associated LDAP group that defines " "room membership; this should be an LDAP " "Distinguished Name according to an implementa" "tion-specific or deployment-specific " "definition of a group."))}. -spec encode_logs(binary(), binary(), boolean()) -> xdata_field(). encode_logs(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roominfo_logs">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("URL for Archived Discussion Logs"))}. -spec encode_roomname(binary(), binary(), boolean()) -> xdata_field(). encode_roomname(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roomconfig_roomname">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Natural-Language Room Name"))}. -spec encode_occupants(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_occupants(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"muc#roominfo_occupants">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Number of occupants"))}. -spec encode_subject(binary(), binary(), boolean()) -> xdata_field(). encode_subject(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roominfo_subject">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Current Discussion Topic"))}. -spec encode_subjectmod(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_subjectmod(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roominfo_subjectmod">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The room subject can be modified by " "participants"))}. -spec encode_pubsub(binary() | undefined, binary(), boolean()) -> xdata_field(). encode_pubsub(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roominfo_pubsub">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("XMPP URI of Associated Publish-Subscribe " "Node"))}. -spec encode_changesubject(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_changesubject(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#roominfo_changesubject">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Occupants May Change the Subject"))}. xmpp-1.4.4/src/muc_register.erl0000644000232200023220000003416613610066730017051 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_register.xdata %% Form type: http://jabber.org/protocol/muc#register %% Document: XEP-0045 -module(muc_register). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("muc_register.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [allow | email | faqentry | first | last | roomnick | url]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/muc#register">>], [<<"muc#register_roomnick">>], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [<<"muc#register_roomnick">>], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, [roomnick]). encode(Cfg, Lang) -> encode(Cfg, Lang, [roomnick]). encode(List, Lang, Required) -> Fs = [case Opt of {allow, Val} -> [encode_allow(Val, Lang, lists:member(allow, Required))]; {email, Val} -> [encode_email(Val, Lang, lists:member(email, Required))]; {faqentry, Val} -> [encode_faqentry(Val, Lang, lists:member(faqentry, Required))]; {first, Val} -> [encode_first(Val, Lang, lists:member(first, Required))]; {last, Val} -> [encode_last(Val, Lang, lists:member(last, Required))]; {roomnick, Val} -> [encode_roomnick(Val, Lang, lists:member(roomnick, Required))]; {url, Val} -> [encode_url(Val, Lang, lists:member(url, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/muc#register">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"muc#register_allow">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#register_allow">>, Required), [{allow, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#register_allow">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#register_allow">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#register_allow">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#register_allow">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#register_allow">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#register_email">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#register_email">>, Required), [{email, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#register_email">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#register_email">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#register_email">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#register_email">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#register_email">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#register_faqentry">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [Value || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#register_faqentry">>, Required), [{faqentry, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#register_faqentry">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#register_first">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#register_first">>, Required), [{first, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#register_first">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#register_first">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#register_first">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#register_first">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#register_first">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#register_last">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#register_last">>, Required), [{last, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#register_last">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#register_last">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#register_last">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#register_last">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#register_last">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#register_roomnick">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#register_roomnick">>, Required), [{roomnick, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#register_roomnick">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#register_roomnick">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#register_roomnick">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#register_roomnick">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#register_roomnick">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#register_url">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#register_url">>, Required), [{url, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#register_url">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#register_url">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#register_url">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#register_url">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#register_url">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_allow(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_allow(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#register_allow">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Allow this person to register with the " "room?"))}. -spec encode_email(binary(), binary(), boolean()) -> xdata_field(). encode_email(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#register_email">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Email Address"))}. -spec encode_faqentry([binary()], binary(), boolean()) -> xdata_field(). encode_faqentry(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> Value end, Opts = [], #xdata_field{var = <<"muc#register_faqentry">>, values = Values, required = IsRequired, type = 'text-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("FAQ Entry"))}. -spec encode_first(binary(), binary(), boolean()) -> xdata_field(). encode_first(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#register_first">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Given Name"))}. -spec encode_last(binary(), binary(), boolean()) -> xdata_field(). encode_last(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#register_last">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Family Name"))}. -spec encode_roomnick(binary(), binary(), boolean()) -> xdata_field(). encode_roomnick(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#register_roomnick">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Nickname"))}. -spec encode_url(binary(), binary(), boolean()) -> xdata_field(). encode_url(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#register_url">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("A Web Page"))}. xmpp-1.4.4/src/muc_request.erl0000644000232200023220000002561113610066730016710 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_request.xdata %% Form type: http://jabber.org/protocol/muc#request %% Document: XEP-0045 -module(muc_request). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("muc_request.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [role | jid | roomnick | request_allow]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/muc#request">>], [<<"muc#role">>], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [<<"muc#role">>], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, [role]). encode(Cfg, Lang) -> encode(Cfg, Lang, [role]). encode(List, Lang, Required) -> Fs = [case Opt of {role, Val} -> [encode_role(Val, default, Lang, lists:member(role, Required))]; {role, Val, Opts} -> [encode_role(Val, Opts, Lang, lists:member(role, Required))]; {jid, Val} -> [encode_jid(Val, Lang, lists:member(jid, Required))]; {roomnick, Val} -> [encode_roomnick(Val, Lang, lists:member(roomnick, Required))]; {request_allow, Val} -> [encode_request_allow(Val, Lang, lists:member(request_allow, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/muc#request">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"muc#role">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [participant]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#role">>, Required), [{role, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#role">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#role">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#role">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#role">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#role">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#jid">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try jid:decode(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#jid">>, Required), [{jid, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#jid">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#jid">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#jid">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#jid">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#jid">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#roomnick">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#roomnick">>, Required), [{roomnick, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#roomnick">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#roomnick">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#roomnick">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#roomnick">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#roomnick">>, XMLNS}}); do_decode([#xdata_field{var = <<"muc#request_allow">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"muc#request_allow">>, Required), [{request_allow, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"muc#request_allow">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"muc#request_allow">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"muc#request_allow">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"muc#request_allow">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"muc#request_allow">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_role(participant | undefined, default | options(participant), binary(), boolean()) -> xdata_field(). encode_role(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Participant")), value = <<"participant">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"muc#role">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Requested role"))}. -spec encode_jid(jid:jid() | undefined, binary(), boolean()) -> xdata_field(). encode_jid(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [jid:encode(Value)] end, Opts = [], #xdata_field{var = <<"muc#jid">>, values = Values, required = IsRequired, type = 'jid-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("User JID"))}. -spec encode_roomnick(binary(), binary(), boolean()) -> xdata_field(). encode_roomnick(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"muc#roomnick">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Nickname"))}. -spec encode_request_allow(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_request_allow(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"muc#request_allow">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Grant voice to this person?"))}. xmpp-1.4.4/src/rfc6121.erl0000644000232200023220000002507213610066730015441 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(rfc6121). -compile(export_all). do_decode(<<"ver">>, <<"urn:xmpp:features:rosterver">>, El, Opts) -> decode_rosterver_feature(<<"urn:xmpp:features:rosterver">>, Opts, El); do_decode(<<"query">>, <<"jabber:iq:roster">>, El, Opts) -> decode_roster_query(<<"jabber:iq:roster">>, Opts, El); do_decode(<<"item">>, <<"jabber:iq:roster">>, El, Opts) -> decode_roster_item(<<"jabber:iq:roster">>, Opts, El); do_decode(<<"group">>, <<"jabber:iq:roster">>, El, Opts) -> decode_roster_group(<<"jabber:iq:roster">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"ver">>, <<"urn:xmpp:features:rosterver">>}, {<<"query">>, <<"jabber:iq:roster">>}, {<<"item">>, <<"jabber:iq:roster">>}, {<<"group">>, <<"jabber:iq:roster">>}]. do_encode({roster_item, _, _, _, _, _} = Item, TopXMLNS) -> encode_roster_item(Item, TopXMLNS); do_encode({roster_query, _, _} = Query, TopXMLNS) -> encode_roster_query(Query, TopXMLNS); do_encode({rosterver_feature} = Ver, TopXMLNS) -> encode_rosterver_feature(Ver, TopXMLNS). do_get_name({roster_item, _, _, _, _, _}) -> <<"item">>; do_get_name({roster_query, _, _}) -> <<"query">>; do_get_name({rosterver_feature}) -> <<"ver">>. do_get_ns({roster_item, _, _, _, _, _}) -> <<"jabber:iq:roster">>; do_get_ns({roster_query, _, _}) -> <<"jabber:iq:roster">>; do_get_ns({rosterver_feature}) -> <<"urn:xmpp:features:rosterver">>. pp(roster_item, 5) -> [jid, name, groups, subscription, ask]; pp(roster_query, 2) -> [items, ver]; pp(rosterver_feature, 0) -> []; pp(_, _) -> no. records() -> [{roster_item, 5}, {roster_query, 2}, {rosterver_feature, 0}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). decode_rosterver_feature(__TopXMLNS, __Opts, {xmlel, <<"ver">>, _attrs, _els}) -> {rosterver_feature}. encode_rosterver_feature({rosterver_feature}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:features:rosterver">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"ver">>, _attrs, _els}. decode_roster_query(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> Items = decode_roster_query_els(__TopXMLNS, __Opts, _els, []), Ver = decode_roster_query_attrs(__TopXMLNS, _attrs, undefined), {roster_query, Items, Ver}. decode_roster_query_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_roster_query_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:roster">> -> decode_roster_query_els(__TopXMLNS, __Opts, _els, [decode_roster_item(<<"jabber:iq:roster">>, __Opts, _el) | Items]); _ -> decode_roster_query_els(__TopXMLNS, __Opts, _els, Items) end; decode_roster_query_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_roster_query_els(__TopXMLNS, __Opts, _els, Items). decode_roster_query_attrs(__TopXMLNS, [{<<"ver">>, _val} | _attrs], _Ver) -> decode_roster_query_attrs(__TopXMLNS, _attrs, _val); decode_roster_query_attrs(__TopXMLNS, [_ | _attrs], Ver) -> decode_roster_query_attrs(__TopXMLNS, _attrs, Ver); decode_roster_query_attrs(__TopXMLNS, [], Ver) -> decode_roster_query_attr_ver(__TopXMLNS, Ver). encode_roster_query({roster_query, Items, Ver}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:roster">>, [], __TopXMLNS), _els = lists:reverse('encode_roster_query_$items'(Items, __NewTopXMLNS, [])), _attrs = encode_roster_query_attr_ver(Ver, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"query">>, _attrs, _els}. 'encode_roster_query_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_roster_query_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_roster_query_$items'(_els, __TopXMLNS, [encode_roster_item(Items, __TopXMLNS) | _acc]). decode_roster_query_attr_ver(__TopXMLNS, undefined) -> undefined; decode_roster_query_attr_ver(__TopXMLNS, _val) -> _val. encode_roster_query_attr_ver(undefined, _acc) -> _acc; encode_roster_query_attr_ver(_val, _acc) -> [{<<"ver">>, _val} | _acc]. decode_roster_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> Groups = decode_roster_item_els(__TopXMLNS, __Opts, _els, []), {Jid, Name, Subscription, Ask} = decode_roster_item_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {roster_item, Jid, Name, Groups, Subscription, Ask}. decode_roster_item_els(__TopXMLNS, __Opts, [], Groups) -> lists:reverse(Groups); decode_roster_item_els(__TopXMLNS, __Opts, [{xmlel, <<"group">>, _attrs, _} = _el | _els], Groups) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:roster">> -> decode_roster_item_els(__TopXMLNS, __Opts, _els, [decode_roster_group(<<"jabber:iq:roster">>, __Opts, _el) | Groups]); _ -> decode_roster_item_els(__TopXMLNS, __Opts, _els, Groups) end; decode_roster_item_els(__TopXMLNS, __Opts, [_ | _els], Groups) -> decode_roster_item_els(__TopXMLNS, __Opts, _els, Groups). decode_roster_item_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Name, Subscription, Ask) -> decode_roster_item_attrs(__TopXMLNS, _attrs, _val, Name, Subscription, Ask); decode_roster_item_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], Jid, _Name, Subscription, Ask) -> decode_roster_item_attrs(__TopXMLNS, _attrs, Jid, _val, Subscription, Ask); decode_roster_item_attrs(__TopXMLNS, [{<<"subscription">>, _val} | _attrs], Jid, Name, _Subscription, Ask) -> decode_roster_item_attrs(__TopXMLNS, _attrs, Jid, Name, _val, Ask); decode_roster_item_attrs(__TopXMLNS, [{<<"ask">>, _val} | _attrs], Jid, Name, Subscription, _Ask) -> decode_roster_item_attrs(__TopXMLNS, _attrs, Jid, Name, Subscription, _val); decode_roster_item_attrs(__TopXMLNS, [_ | _attrs], Jid, Name, Subscription, Ask) -> decode_roster_item_attrs(__TopXMLNS, _attrs, Jid, Name, Subscription, Ask); decode_roster_item_attrs(__TopXMLNS, [], Jid, Name, Subscription, Ask) -> {decode_roster_item_attr_jid(__TopXMLNS, Jid), decode_roster_item_attr_name(__TopXMLNS, Name), decode_roster_item_attr_subscription(__TopXMLNS, Subscription), decode_roster_item_attr_ask(__TopXMLNS, Ask)}. encode_roster_item({roster_item, Jid, Name, Groups, Subscription, Ask}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:roster">>, [], __TopXMLNS), _els = lists:reverse('encode_roster_item_$groups'(Groups, __NewTopXMLNS, [])), _attrs = encode_roster_item_attr_ask(Ask, encode_roster_item_attr_subscription(Subscription, encode_roster_item_attr_name(Name, encode_roster_item_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"item">>, _attrs, _els}. 'encode_roster_item_$groups'([], __TopXMLNS, _acc) -> _acc; 'encode_roster_item_$groups'([Groups | _els], __TopXMLNS, _acc) -> 'encode_roster_item_$groups'(_els, __TopXMLNS, [encode_roster_group(Groups, __TopXMLNS) | _acc]). decode_roster_item_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"item">>, __TopXMLNS}}); decode_roster_item_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_roster_item_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_roster_item_attr_name(__TopXMLNS, undefined) -> <<>>; decode_roster_item_attr_name(__TopXMLNS, _val) -> _val. encode_roster_item_attr_name(<<>>, _acc) -> _acc; encode_roster_item_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_roster_item_attr_subscription(__TopXMLNS, undefined) -> none; decode_roster_item_attr_subscription(__TopXMLNS, _val) -> case catch dec_enum(_val, [none, to, from, both, remove]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"subscription">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_roster_item_attr_subscription(none, _acc) -> _acc; encode_roster_item_attr_subscription(_val, _acc) -> [{<<"subscription">>, enc_enum(_val)} | _acc]. decode_roster_item_attr_ask(__TopXMLNS, undefined) -> undefined; decode_roster_item_attr_ask(__TopXMLNS, _val) -> case catch dec_enum(_val, [subscribe]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"ask">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_roster_item_attr_ask(undefined, _acc) -> _acc; encode_roster_item_attr_ask(_val, _acc) -> [{<<"ask">>, enc_enum(_val)} | _acc]. decode_roster_group(__TopXMLNS, __Opts, {xmlel, <<"group">>, _attrs, _els}) -> Cdata = decode_roster_group_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_roster_group_els(__TopXMLNS, __Opts, [], Cdata) -> decode_roster_group_cdata(__TopXMLNS, Cdata); decode_roster_group_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_roster_group_els(__TopXMLNS, __Opts, _els, <>); decode_roster_group_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_roster_group_els(__TopXMLNS, __Opts, _els, Cdata). encode_roster_group(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:roster">>, [], __TopXMLNS), _els = encode_roster_group_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"group">>, _attrs, _els}. decode_roster_group_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"group">>, __TopXMLNS}}); decode_roster_group_cdata(__TopXMLNS, _val) -> _val. encode_roster_group_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0249.erl0000644000232200023220000001250213610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0249). -compile(export_all). do_decode(<<"x">>, <<"jabber:x:conference">>, El, Opts) -> decode_x_conference(<<"jabber:x:conference">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"x">>, <<"jabber:x:conference">>}]. do_encode({x_conference, _, _, _, _, _} = X, TopXMLNS) -> encode_x_conference(X, TopXMLNS). do_get_name({x_conference, _, _, _, _, _}) -> <<"x">>. do_get_ns({x_conference, _, _, _, _, _}) -> <<"jabber:x:conference">>. pp(x_conference, 5) -> [jid, password, reason, continue, thread]; pp(_, _) -> no. records() -> [{x_conference, 5}]. dec_bool(<<"false">>) -> false; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"1">>) -> true. enc_bool(false) -> <<"false">>; enc_bool(true) -> <<"true">>. decode_x_conference(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> {Jid, Password, Reason, Thread, Continue} = decode_x_conference_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {x_conference, Jid, Password, Reason, Continue, Thread}. decode_x_conference_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Password, Reason, Thread, Continue) -> decode_x_conference_attrs(__TopXMLNS, _attrs, _val, Password, Reason, Thread, Continue); decode_x_conference_attrs(__TopXMLNS, [{<<"password">>, _val} | _attrs], Jid, _Password, Reason, Thread, Continue) -> decode_x_conference_attrs(__TopXMLNS, _attrs, Jid, _val, Reason, Thread, Continue); decode_x_conference_attrs(__TopXMLNS, [{<<"reason">>, _val} | _attrs], Jid, Password, _Reason, Thread, Continue) -> decode_x_conference_attrs(__TopXMLNS, _attrs, Jid, Password, _val, Thread, Continue); decode_x_conference_attrs(__TopXMLNS, [{<<"thread">>, _val} | _attrs], Jid, Password, Reason, _Thread, Continue) -> decode_x_conference_attrs(__TopXMLNS, _attrs, Jid, Password, Reason, _val, Continue); decode_x_conference_attrs(__TopXMLNS, [{<<"continue">>, _val} | _attrs], Jid, Password, Reason, Thread, _Continue) -> decode_x_conference_attrs(__TopXMLNS, _attrs, Jid, Password, Reason, Thread, _val); decode_x_conference_attrs(__TopXMLNS, [_ | _attrs], Jid, Password, Reason, Thread, Continue) -> decode_x_conference_attrs(__TopXMLNS, _attrs, Jid, Password, Reason, Thread, Continue); decode_x_conference_attrs(__TopXMLNS, [], Jid, Password, Reason, Thread, Continue) -> {decode_x_conference_attr_jid(__TopXMLNS, Jid), decode_x_conference_attr_password(__TopXMLNS, Password), decode_x_conference_attr_reason(__TopXMLNS, Reason), decode_x_conference_attr_thread(__TopXMLNS, Thread), decode_x_conference_attr_continue(__TopXMLNS, Continue)}. encode_x_conference({x_conference, Jid, Password, Reason, Continue, Thread}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:conference">>, [], __TopXMLNS), _els = [], _attrs = encode_x_conference_attr_continue(Continue, encode_x_conference_attr_thread(Thread, encode_x_conference_attr_reason(Reason, encode_x_conference_attr_password(Password, encode_x_conference_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"x">>, _attrs, _els}. decode_x_conference_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"x">>, __TopXMLNS}}); decode_x_conference_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"x">>, __TopXMLNS}}); _res -> _res end. encode_x_conference_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_x_conference_attr_password(__TopXMLNS, undefined) -> <<>>; decode_x_conference_attr_password(__TopXMLNS, _val) -> _val. encode_x_conference_attr_password(<<>>, _acc) -> _acc; encode_x_conference_attr_password(_val, _acc) -> [{<<"password">>, _val} | _acc]. decode_x_conference_attr_reason(__TopXMLNS, undefined) -> <<>>; decode_x_conference_attr_reason(__TopXMLNS, _val) -> _val. encode_x_conference_attr_reason(<<>>, _acc) -> _acc; encode_x_conference_attr_reason(_val, _acc) -> [{<<"reason">>, _val} | _acc]. decode_x_conference_attr_thread(__TopXMLNS, undefined) -> <<>>; decode_x_conference_attr_thread(__TopXMLNS, _val) -> _val. encode_x_conference_attr_thread(<<>>, _acc) -> _acc; encode_x_conference_attr_thread(_val, _acc) -> [{<<"thread">>, _val} | _acc]. decode_x_conference_attr_continue(__TopXMLNS, undefined) -> undefined; decode_x_conference_attr_continue(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"continue">>, <<"x">>, __TopXMLNS}}); _res -> _res end. encode_x_conference_attr_continue(undefined, _acc) -> _acc; encode_x_conference_attr_continue(_val, _acc) -> [{<<"continue">>, enc_bool(_val)} | _acc]. xmpp-1.4.4/src/xep0363.erl0000644000232200023220000011144513610066730015465 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0363). -compile(export_all). do_decode(<<"retry">>, <<"urn:xmpp:http:upload:0">>, El, Opts) -> decode_upload_retry(<<"urn:xmpp:http:upload:0">>, Opts, El); do_decode(<<"file-too-large">>, <<"urn:xmpp:http:upload:0">>, El, Opts) -> decode_upload_file_too_large(<<"urn:xmpp:http:upload:0">>, Opts, El); do_decode(<<"file-too-large">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_file_too_large(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"file-too-large">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_file_too_large(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"max-file-size">>, <<"urn:xmpp:http:upload:0">>, El, Opts) -> decode_upload_max_file_size(<<"urn:xmpp:http:upload:0">>, Opts, El); do_decode(<<"max-file-size">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_max_file_size(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"max-file-size">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_max_file_size(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"slot">>, <<"urn:xmpp:http:upload:0">>, El, Opts) -> decode_upload_slot_0(<<"urn:xmpp:http:upload:0">>, Opts, El); do_decode(<<"put">>, <<"urn:xmpp:http:upload:0">>, El, Opts) -> decode_upload_put_0(<<"urn:xmpp:http:upload:0">>, Opts, El); do_decode(<<"get">>, <<"urn:xmpp:http:upload:0">>, El, Opts) -> decode_upload_get_0(<<"urn:xmpp:http:upload:0">>, Opts, El); do_decode(<<"request">>, <<"urn:xmpp:http:upload:0">>, El, Opts) -> decode_upload_request_0(<<"urn:xmpp:http:upload:0">>, Opts, El); do_decode(<<"slot">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_slot(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"slot">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_slot(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"put">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_put(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"put">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_put(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"get">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_get(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"get">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_get(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"request">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_request(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"request">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_request(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"content-type">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_content_type(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"content-type">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_content_type(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"size">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_size(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"size">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_size(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(<<"filename">>, <<"urn:xmpp:http:upload">>, El, Opts) -> decode_upload_filename(<<"urn:xmpp:http:upload">>, Opts, El); do_decode(<<"filename">>, <<"eu:siacs:conversations:http:upload">>, El, Opts) -> decode_upload_filename(<<"eu:siacs:conversations:http:upload">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"retry">>, <<"urn:xmpp:http:upload:0">>}, {<<"file-too-large">>, <<"urn:xmpp:http:upload:0">>}, {<<"file-too-large">>, <<"urn:xmpp:http:upload">>}, {<<"file-too-large">>, <<"eu:siacs:conversations:http:upload">>}, {<<"max-file-size">>, <<"urn:xmpp:http:upload:0">>}, {<<"max-file-size">>, <<"urn:xmpp:http:upload">>}, {<<"max-file-size">>, <<"eu:siacs:conversations:http:upload">>}, {<<"slot">>, <<"urn:xmpp:http:upload:0">>}, {<<"put">>, <<"urn:xmpp:http:upload:0">>}, {<<"get">>, <<"urn:xmpp:http:upload:0">>}, {<<"request">>, <<"urn:xmpp:http:upload:0">>}, {<<"slot">>, <<"urn:xmpp:http:upload">>}, {<<"slot">>, <<"eu:siacs:conversations:http:upload">>}, {<<"put">>, <<"urn:xmpp:http:upload">>}, {<<"put">>, <<"eu:siacs:conversations:http:upload">>}, {<<"get">>, <<"urn:xmpp:http:upload">>}, {<<"get">>, <<"eu:siacs:conversations:http:upload">>}, {<<"request">>, <<"urn:xmpp:http:upload">>}, {<<"request">>, <<"eu:siacs:conversations:http:upload">>}, {<<"content-type">>, <<"urn:xmpp:http:upload">>}, {<<"content-type">>, <<"eu:siacs:conversations:http:upload">>}, {<<"size">>, <<"urn:xmpp:http:upload">>}, {<<"size">>, <<"eu:siacs:conversations:http:upload">>}, {<<"filename">>, <<"urn:xmpp:http:upload">>}, {<<"filename">>, <<"eu:siacs:conversations:http:upload">>}]. do_encode({upload_request, _, _, _, _} = Request, TopXMLNS) -> encode_upload_request(Request, TopXMLNS); do_encode({upload_slot, _, _, _} = Slot, TopXMLNS) -> encode_upload_slot(Slot, TopXMLNS); do_encode({upload_request_0, _, _, _, <<"urn:xmpp:http:upload:0">>} = Request, TopXMLNS) -> encode_upload_request_0(Request, TopXMLNS); do_encode({upload_request_0, _, _, _, <<>>} = Request, TopXMLNS = <<"urn:xmpp:http:upload:0">>) -> encode_upload_request_0(Request, TopXMLNS); do_encode({upload_slot_0, _, _, <<"urn:xmpp:http:upload:0">>} = Slot, TopXMLNS) -> encode_upload_slot_0(Slot, TopXMLNS); do_encode({upload_slot_0, _, _, <<>>} = Slot, TopXMLNS = <<"urn:xmpp:http:upload:0">>) -> encode_upload_slot_0(Slot, TopXMLNS); do_encode({upload_file_too_large, _, _} = File_too_large, TopXMLNS) -> encode_upload_file_too_large(File_too_large, TopXMLNS); do_encode({upload_retry, _} = Retry, TopXMLNS) -> encode_upload_retry(Retry, TopXMLNS). do_get_name({upload_file_too_large, _, _}) -> <<"file-too-large">>; do_get_name({upload_request, _, _, _, _}) -> <<"request">>; do_get_name({upload_request_0, _, _, _, _}) -> <<"request">>; do_get_name({upload_retry, _}) -> <<"retry">>; do_get_name({upload_slot, _, _, _}) -> <<"slot">>; do_get_name({upload_slot_0, _, _, _}) -> <<"slot">>. do_get_ns({upload_file_too_large, _, Xmlns}) -> Xmlns; do_get_ns({upload_request, _, _, _, Xmlns}) -> Xmlns; do_get_ns({upload_request_0, _, _, _, Xmlns}) -> Xmlns; do_get_ns({upload_retry, _}) -> <<"urn:xmpp:http:upload:0">>; do_get_ns({upload_slot, _, _, Xmlns}) -> Xmlns; do_get_ns({upload_slot_0, _, _, Xmlns}) -> Xmlns. pp(upload_request, 4) -> [filename, size, 'content-type', xmlns]; pp(upload_slot, 3) -> [get, put, xmlns]; pp(upload_request_0, 4) -> [filename, size, 'content-type', xmlns]; pp(upload_slot_0, 3) -> [get, put, xmlns]; pp(upload_file_too_large, 2) -> ['max-file-size', xmlns]; pp(upload_retry, 1) -> [stamp]; pp(_, _) -> no. records() -> [{upload_request, 4}, {upload_slot, 3}, {upload_request_0, 4}, {upload_slot_0, 3}, {upload_file_too_large, 2}, {upload_retry, 1}]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_int(Int) -> erlang:integer_to_binary(Int). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_upload_retry(__TopXMLNS, __Opts, {xmlel, <<"retry">>, _attrs, _els}) -> Stamp = decode_upload_retry_attrs(__TopXMLNS, _attrs, undefined), {upload_retry, Stamp}. decode_upload_retry_attrs(__TopXMLNS, [{<<"stamp">>, _val} | _attrs], _Stamp) -> decode_upload_retry_attrs(__TopXMLNS, _attrs, _val); decode_upload_retry_attrs(__TopXMLNS, [_ | _attrs], Stamp) -> decode_upload_retry_attrs(__TopXMLNS, _attrs, Stamp); decode_upload_retry_attrs(__TopXMLNS, [], Stamp) -> decode_upload_retry_attr_stamp(__TopXMLNS, Stamp). encode_upload_retry({upload_retry, Stamp}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:http:upload:0">>, [], __TopXMLNS), _els = [], _attrs = encode_upload_retry_attr_stamp(Stamp, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"retry">>, _attrs, _els}. decode_upload_retry_attr_stamp(__TopXMLNS, undefined) -> undefined; decode_upload_retry_attr_stamp(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"stamp">>, <<"retry">>, __TopXMLNS}}); _res -> _res end. encode_upload_retry_attr_stamp(undefined, _acc) -> _acc; encode_upload_retry_attr_stamp(_val, _acc) -> [{<<"stamp">>, enc_utc(_val)} | _acc]. decode_upload_file_too_large(__TopXMLNS, __Opts, {xmlel, <<"file-too-large">>, _attrs, _els}) -> Max_file_size = decode_upload_file_too_large_els(__TopXMLNS, __Opts, _els, undefined), Xmlns = decode_upload_file_too_large_attrs(__TopXMLNS, _attrs, undefined), {upload_file_too_large, Max_file_size, Xmlns}. decode_upload_file_too_large_els(__TopXMLNS, __Opts, [], Max_file_size) -> Max_file_size; decode_upload_file_too_large_els(__TopXMLNS, __Opts, [{xmlel, <<"max-file-size">>, _attrs, _} = _el | _els], Max_file_size) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload:0">> -> decode_upload_file_too_large_els(__TopXMLNS, __Opts, _els, decode_upload_max_file_size(<<"urn:xmpp:http:upload:0">>, __Opts, _el)); <<"urn:xmpp:http:upload">> -> decode_upload_file_too_large_els(__TopXMLNS, __Opts, _els, decode_upload_max_file_size(<<"urn:xmpp:http:upload">>, __Opts, _el)); <<"eu:siacs:conversations:http:upload">> -> decode_upload_file_too_large_els(__TopXMLNS, __Opts, _els, decode_upload_max_file_size(<<"eu:siacs:conversations:http:upload">>, __Opts, _el)); _ -> decode_upload_file_too_large_els(__TopXMLNS, __Opts, _els, Max_file_size) end; decode_upload_file_too_large_els(__TopXMLNS, __Opts, [_ | _els], Max_file_size) -> decode_upload_file_too_large_els(__TopXMLNS, __Opts, _els, Max_file_size). decode_upload_file_too_large_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns) -> decode_upload_file_too_large_attrs(__TopXMLNS, _attrs, _val); decode_upload_file_too_large_attrs(__TopXMLNS, [_ | _attrs], Xmlns) -> decode_upload_file_too_large_attrs(__TopXMLNS, _attrs, Xmlns); decode_upload_file_too_large_attrs(__TopXMLNS, [], Xmlns) -> decode_upload_file_too_large_attr_xmlns(__TopXMLNS, Xmlns). encode_upload_file_too_large({upload_file_too_large, Max_file_size, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:http:upload:0">>, <<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = lists:reverse('encode_upload_file_too_large_$max-file-size'(Max_file_size, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"file-too-large">>, _attrs, _els}. 'encode_upload_file_too_large_$max-file-size'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_upload_file_too_large_$max-file-size'(Max_file_size, __TopXMLNS, _acc) -> [encode_upload_max_file_size(Max_file_size, __TopXMLNS) | _acc]. decode_upload_file_too_large_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_upload_file_too_large_attr_xmlns(__TopXMLNS, _val) -> _val. decode_upload_max_file_size(__TopXMLNS, __Opts, {xmlel, <<"max-file-size">>, _attrs, _els}) -> Cdata = decode_upload_max_file_size_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_upload_max_file_size_els(__TopXMLNS, __Opts, [], Cdata) -> decode_upload_max_file_size_cdata(__TopXMLNS, Cdata); decode_upload_max_file_size_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_upload_max_file_size_els(__TopXMLNS, __Opts, _els, <>); decode_upload_max_file_size_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_upload_max_file_size_els(__TopXMLNS, __Opts, _els, Cdata). encode_upload_max_file_size(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:http:upload:0">>, <<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = encode_upload_max_file_size_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"max-file-size">>, _attrs, _els}. decode_upload_max_file_size_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"max-file-size">>, __TopXMLNS}}); decode_upload_max_file_size_cdata(__TopXMLNS, _val) -> case catch dec_int(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"max-file-size">>, __TopXMLNS}}); _res -> _res end. encode_upload_max_file_size_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_upload_slot_0(__TopXMLNS, __Opts, {xmlel, <<"slot">>, _attrs, _els}) -> {Put, Get} = decode_upload_slot_0_els(__TopXMLNS, __Opts, _els, error, error), Xmlns = decode_upload_slot_0_attrs(__TopXMLNS, _attrs, undefined), {upload_slot_0, Get, Put, Xmlns}. decode_upload_slot_0_els(__TopXMLNS, __Opts, [], Put, Get) -> {case Put of error -> erlang:error({xmpp_codec, {missing_tag, <<"put">>, __TopXMLNS}}); {value, Put1} -> Put1 end, case Get of error -> erlang:error({xmpp_codec, {missing_tag, <<"get">>, __TopXMLNS}}); {value, Get1} -> Get1 end}; decode_upload_slot_0_els(__TopXMLNS, __Opts, [{xmlel, <<"get">>, _attrs, _} = _el | _els], Put, Get) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload:0">> -> decode_upload_slot_0_els(__TopXMLNS, __Opts, _els, Put, {value, decode_upload_get_0(<<"urn:xmpp:http:upload:0">>, __Opts, _el)}); _ -> decode_upload_slot_0_els(__TopXMLNS, __Opts, _els, Put, Get) end; decode_upload_slot_0_els(__TopXMLNS, __Opts, [{xmlel, <<"put">>, _attrs, _} = _el | _els], Put, Get) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload:0">> -> decode_upload_slot_0_els(__TopXMLNS, __Opts, _els, {value, decode_upload_put_0(<<"urn:xmpp:http:upload:0">>, __Opts, _el)}, Get); _ -> decode_upload_slot_0_els(__TopXMLNS, __Opts, _els, Put, Get) end; decode_upload_slot_0_els(__TopXMLNS, __Opts, [_ | _els], Put, Get) -> decode_upload_slot_0_els(__TopXMLNS, __Opts, _els, Put, Get). decode_upload_slot_0_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns) -> decode_upload_slot_0_attrs(__TopXMLNS, _attrs, _val); decode_upload_slot_0_attrs(__TopXMLNS, [_ | _attrs], Xmlns) -> decode_upload_slot_0_attrs(__TopXMLNS, _attrs, Xmlns); decode_upload_slot_0_attrs(__TopXMLNS, [], Xmlns) -> decode_upload_slot_0_attr_xmlns(__TopXMLNS, Xmlns). encode_upload_slot_0({upload_slot_0, Get, Put, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:http:upload:0">>], __TopXMLNS), _els = lists:reverse('encode_upload_slot_0_$put'(Put, __NewTopXMLNS, 'encode_upload_slot_0_$get'(Get, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"slot">>, _attrs, _els}. 'encode_upload_slot_0_$put'(Put, __TopXMLNS, _acc) -> [encode_upload_put_0(Put, __TopXMLNS) | _acc]. 'encode_upload_slot_0_$get'(Get, __TopXMLNS, _acc) -> [encode_upload_get_0(Get, __TopXMLNS) | _acc]. decode_upload_slot_0_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_upload_slot_0_attr_xmlns(__TopXMLNS, _val) -> _val. decode_upload_put_0(__TopXMLNS, __Opts, {xmlel, <<"put">>, _attrs, _els}) -> Url = decode_upload_put_0_attrs(__TopXMLNS, _attrs, undefined), Url. decode_upload_put_0_attrs(__TopXMLNS, [{<<"url">>, _val} | _attrs], _Url) -> decode_upload_put_0_attrs(__TopXMLNS, _attrs, _val); decode_upload_put_0_attrs(__TopXMLNS, [_ | _attrs], Url) -> decode_upload_put_0_attrs(__TopXMLNS, _attrs, Url); decode_upload_put_0_attrs(__TopXMLNS, [], Url) -> decode_upload_put_0_attr_url(__TopXMLNS, Url). encode_upload_put_0(Url, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:http:upload:0">>, [], __TopXMLNS), _els = [], _attrs = encode_upload_put_0_attr_url(Url, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"put">>, _attrs, _els}. decode_upload_put_0_attr_url(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"url">>, <<"put">>, __TopXMLNS}}); decode_upload_put_0_attr_url(__TopXMLNS, _val) -> _val. encode_upload_put_0_attr_url(_val, _acc) -> [{<<"url">>, _val} | _acc]. decode_upload_get_0(__TopXMLNS, __Opts, {xmlel, <<"get">>, _attrs, _els}) -> Url = decode_upload_get_0_attrs(__TopXMLNS, _attrs, undefined), Url. decode_upload_get_0_attrs(__TopXMLNS, [{<<"url">>, _val} | _attrs], _Url) -> decode_upload_get_0_attrs(__TopXMLNS, _attrs, _val); decode_upload_get_0_attrs(__TopXMLNS, [_ | _attrs], Url) -> decode_upload_get_0_attrs(__TopXMLNS, _attrs, Url); decode_upload_get_0_attrs(__TopXMLNS, [], Url) -> decode_upload_get_0_attr_url(__TopXMLNS, Url). encode_upload_get_0(Url, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:http:upload:0">>, [], __TopXMLNS), _els = [], _attrs = encode_upload_get_0_attr_url(Url, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"get">>, _attrs, _els}. decode_upload_get_0_attr_url(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"url">>, <<"get">>, __TopXMLNS}}); decode_upload_get_0_attr_url(__TopXMLNS, _val) -> _val. encode_upload_get_0_attr_url(_val, _acc) -> [{<<"url">>, _val} | _acc]. decode_upload_request_0(__TopXMLNS, __Opts, {xmlel, <<"request">>, _attrs, _els}) -> {Xmlns, Filename, Size, Content_type} = decode_upload_request_0_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {upload_request_0, Filename, Size, Content_type, Xmlns}. decode_upload_request_0_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns, Filename, Size, Content_type) -> decode_upload_request_0_attrs(__TopXMLNS, _attrs, _val, Filename, Size, Content_type); decode_upload_request_0_attrs(__TopXMLNS, [{<<"filename">>, _val} | _attrs], Xmlns, _Filename, Size, Content_type) -> decode_upload_request_0_attrs(__TopXMLNS, _attrs, Xmlns, _val, Size, Content_type); decode_upload_request_0_attrs(__TopXMLNS, [{<<"size">>, _val} | _attrs], Xmlns, Filename, _Size, Content_type) -> decode_upload_request_0_attrs(__TopXMLNS, _attrs, Xmlns, Filename, _val, Content_type); decode_upload_request_0_attrs(__TopXMLNS, [{<<"content-type">>, _val} | _attrs], Xmlns, Filename, Size, _Content_type) -> decode_upload_request_0_attrs(__TopXMLNS, _attrs, Xmlns, Filename, Size, _val); decode_upload_request_0_attrs(__TopXMLNS, [_ | _attrs], Xmlns, Filename, Size, Content_type) -> decode_upload_request_0_attrs(__TopXMLNS, _attrs, Xmlns, Filename, Size, Content_type); decode_upload_request_0_attrs(__TopXMLNS, [], Xmlns, Filename, Size, Content_type) -> {decode_upload_request_0_attr_xmlns(__TopXMLNS, Xmlns), decode_upload_request_0_attr_filename(__TopXMLNS, Filename), decode_upload_request_0_attr_size(__TopXMLNS, Size), 'decode_upload_request_0_attr_content-type'(__TopXMLNS, Content_type)}. encode_upload_request_0({upload_request_0, Filename, Size, Content_type, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:http:upload:0">>], __TopXMLNS), _els = [], _attrs = 'encode_upload_request_0_attr_content-type'(Content_type, encode_upload_request_0_attr_size(Size, encode_upload_request_0_attr_filename(Filename, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"request">>, _attrs, _els}. decode_upload_request_0_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_upload_request_0_attr_xmlns(__TopXMLNS, _val) -> _val. decode_upload_request_0_attr_filename(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"filename">>, <<"request">>, __TopXMLNS}}); decode_upload_request_0_attr_filename(__TopXMLNS, _val) -> _val. encode_upload_request_0_attr_filename(_val, _acc) -> [{<<"filename">>, _val} | _acc]. decode_upload_request_0_attr_size(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"size">>, <<"request">>, __TopXMLNS}}); decode_upload_request_0_attr_size(__TopXMLNS, _val) -> case catch dec_int(_val, 1, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"size">>, <<"request">>, __TopXMLNS}}); _res -> _res end. encode_upload_request_0_attr_size(_val, _acc) -> [{<<"size">>, enc_int(_val)} | _acc]. 'decode_upload_request_0_attr_content-type'(__TopXMLNS, undefined) -> <<>>; 'decode_upload_request_0_attr_content-type'(__TopXMLNS, _val) -> _val. 'encode_upload_request_0_attr_content-type'(<<>>, _acc) -> _acc; 'encode_upload_request_0_attr_content-type'(_val, _acc) -> [{<<"content-type">>, _val} | _acc]. decode_upload_slot(__TopXMLNS, __Opts, {xmlel, <<"slot">>, _attrs, _els}) -> {Put, Get} = decode_upload_slot_els(__TopXMLNS, __Opts, _els, undefined, undefined), Xmlns = decode_upload_slot_attrs(__TopXMLNS, _attrs, undefined), {upload_slot, Get, Put, Xmlns}. decode_upload_slot_els(__TopXMLNS, __Opts, [], Put, Get) -> {Put, Get}; decode_upload_slot_els(__TopXMLNS, __Opts, [{xmlel, <<"get">>, _attrs, _} = _el | _els], Put, Get) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload">> -> decode_upload_slot_els(__TopXMLNS, __Opts, _els, Put, decode_upload_get(<<"urn:xmpp:http:upload">>, __Opts, _el)); <<"eu:siacs:conversations:http:upload">> -> decode_upload_slot_els(__TopXMLNS, __Opts, _els, Put, decode_upload_get(<<"eu:siacs:conversations:http:upload">>, __Opts, _el)); _ -> decode_upload_slot_els(__TopXMLNS, __Opts, _els, Put, Get) end; decode_upload_slot_els(__TopXMLNS, __Opts, [{xmlel, <<"put">>, _attrs, _} = _el | _els], Put, Get) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload">> -> decode_upload_slot_els(__TopXMLNS, __Opts, _els, decode_upload_put(<<"urn:xmpp:http:upload">>, __Opts, _el), Get); <<"eu:siacs:conversations:http:upload">> -> decode_upload_slot_els(__TopXMLNS, __Opts, _els, decode_upload_put(<<"eu:siacs:conversations:http:upload">>, __Opts, _el), Get); _ -> decode_upload_slot_els(__TopXMLNS, __Opts, _els, Put, Get) end; decode_upload_slot_els(__TopXMLNS, __Opts, [_ | _els], Put, Get) -> decode_upload_slot_els(__TopXMLNS, __Opts, _els, Put, Get). decode_upload_slot_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns) -> decode_upload_slot_attrs(__TopXMLNS, _attrs, _val); decode_upload_slot_attrs(__TopXMLNS, [_ | _attrs], Xmlns) -> decode_upload_slot_attrs(__TopXMLNS, _attrs, Xmlns); decode_upload_slot_attrs(__TopXMLNS, [], Xmlns) -> decode_upload_slot_attr_xmlns(__TopXMLNS, Xmlns). encode_upload_slot({upload_slot, Get, Put, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = lists:reverse('encode_upload_slot_$put'(Put, __NewTopXMLNS, 'encode_upload_slot_$get'(Get, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"slot">>, _attrs, _els}. 'encode_upload_slot_$put'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_upload_slot_$put'(Put, __TopXMLNS, _acc) -> [encode_upload_put(Put, __TopXMLNS) | _acc]. 'encode_upload_slot_$get'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_upload_slot_$get'(Get, __TopXMLNS, _acc) -> [encode_upload_get(Get, __TopXMLNS) | _acc]. decode_upload_slot_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_upload_slot_attr_xmlns(__TopXMLNS, _val) -> _val. decode_upload_put(__TopXMLNS, __Opts, {xmlel, <<"put">>, _attrs, _els}) -> Cdata = decode_upload_put_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_upload_put_els(__TopXMLNS, __Opts, [], Cdata) -> decode_upload_put_cdata(__TopXMLNS, Cdata); decode_upload_put_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_upload_put_els(__TopXMLNS, __Opts, _els, <>); decode_upload_put_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_upload_put_els(__TopXMLNS, __Opts, _els, Cdata). encode_upload_put(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = encode_upload_put_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"put">>, _attrs, _els}. decode_upload_put_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"put">>, __TopXMLNS}}); decode_upload_put_cdata(__TopXMLNS, _val) -> _val. encode_upload_put_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_upload_get(__TopXMLNS, __Opts, {xmlel, <<"get">>, _attrs, _els}) -> Cdata = decode_upload_get_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_upload_get_els(__TopXMLNS, __Opts, [], Cdata) -> decode_upload_get_cdata(__TopXMLNS, Cdata); decode_upload_get_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_upload_get_els(__TopXMLNS, __Opts, _els, <>); decode_upload_get_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_upload_get_els(__TopXMLNS, __Opts, _els, Cdata). encode_upload_get(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = encode_upload_get_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"get">>, _attrs, _els}. decode_upload_get_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"get">>, __TopXMLNS}}); decode_upload_get_cdata(__TopXMLNS, _val) -> _val. encode_upload_get_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_upload_request(__TopXMLNS, __Opts, {xmlel, <<"request">>, _attrs, _els}) -> {Content_type, Size, Filename} = decode_upload_request_els(__TopXMLNS, __Opts, _els, <<>>, error, error), Xmlns = decode_upload_request_attrs(__TopXMLNS, _attrs, undefined), {upload_request, Filename, Size, Content_type, Xmlns}. decode_upload_request_els(__TopXMLNS, __Opts, [], Content_type, Size, Filename) -> {Content_type, case Size of error -> erlang:error({xmpp_codec, {missing_tag, <<"size">>, __TopXMLNS}}); {value, Size1} -> Size1 end, case Filename of error -> erlang:error({xmpp_codec, {missing_tag, <<"filename">>, __TopXMLNS}}); {value, Filename1} -> Filename1 end}; decode_upload_request_els(__TopXMLNS, __Opts, [{xmlel, <<"filename">>, _attrs, _} = _el | _els], Content_type, Size, Filename) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload">> -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, Size, {value, decode_upload_filename(<<"urn:xmpp:http:upload">>, __Opts, _el)}); <<"eu:siacs:conversations:http:upload">> -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, Size, {value, decode_upload_filename(<<"eu:siacs:conversations:http:upload">>, __Opts, _el)}); _ -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, Size, Filename) end; decode_upload_request_els(__TopXMLNS, __Opts, [{xmlel, <<"size">>, _attrs, _} = _el | _els], Content_type, Size, Filename) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload">> -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, {value, decode_upload_size(<<"urn:xmpp:http:upload">>, __Opts, _el)}, Filename); <<"eu:siacs:conversations:http:upload">> -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, {value, decode_upload_size(<<"eu:siacs:conversations:http:upload">>, __Opts, _el)}, Filename); _ -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, Size, Filename) end; decode_upload_request_els(__TopXMLNS, __Opts, [{xmlel, <<"content-type">>, _attrs, _} = _el | _els], Content_type, Size, Filename) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:http:upload">> -> decode_upload_request_els(__TopXMLNS, __Opts, _els, decode_upload_content_type(<<"urn:xmpp:http:upload">>, __Opts, _el), Size, Filename); <<"eu:siacs:conversations:http:upload">> -> decode_upload_request_els(__TopXMLNS, __Opts, _els, decode_upload_content_type(<<"eu:siacs:conversations:http:upload">>, __Opts, _el), Size, Filename); _ -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, Size, Filename) end; decode_upload_request_els(__TopXMLNS, __Opts, [_ | _els], Content_type, Size, Filename) -> decode_upload_request_els(__TopXMLNS, __Opts, _els, Content_type, Size, Filename). decode_upload_request_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], _Xmlns) -> decode_upload_request_attrs(__TopXMLNS, _attrs, _val); decode_upload_request_attrs(__TopXMLNS, [_ | _attrs], Xmlns) -> decode_upload_request_attrs(__TopXMLNS, _attrs, Xmlns); decode_upload_request_attrs(__TopXMLNS, [], Xmlns) -> decode_upload_request_attr_xmlns(__TopXMLNS, Xmlns). encode_upload_request({upload_request, Filename, Size, Content_type, Xmlns}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = lists:reverse('encode_upload_request_$content-type'(Content_type, __NewTopXMLNS, 'encode_upload_request_$size'(Size, __NewTopXMLNS, 'encode_upload_request_$filename'(Filename, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"request">>, _attrs, _els}. 'encode_upload_request_$content-type'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_upload_request_$content-type'(Content_type, __TopXMLNS, _acc) -> [encode_upload_content_type(Content_type, __TopXMLNS) | _acc]. 'encode_upload_request_$size'(Size, __TopXMLNS, _acc) -> [encode_upload_size(Size, __TopXMLNS) | _acc]. 'encode_upload_request_$filename'(Filename, __TopXMLNS, _acc) -> [encode_upload_filename(Filename, __TopXMLNS) | _acc]. decode_upload_request_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_upload_request_attr_xmlns(__TopXMLNS, _val) -> _val. decode_upload_content_type(__TopXMLNS, __Opts, {xmlel, <<"content-type">>, _attrs, _els}) -> Cdata = decode_upload_content_type_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_upload_content_type_els(__TopXMLNS, __Opts, [], Cdata) -> decode_upload_content_type_cdata(__TopXMLNS, Cdata); decode_upload_content_type_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_upload_content_type_els(__TopXMLNS, __Opts, _els, <>); decode_upload_content_type_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_upload_content_type_els(__TopXMLNS, __Opts, _els, Cdata). encode_upload_content_type(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = encode_upload_content_type_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"content-type">>, _attrs, _els}. decode_upload_content_type_cdata(__TopXMLNS, <<>>) -> <<>>; decode_upload_content_type_cdata(__TopXMLNS, _val) -> _val. encode_upload_content_type_cdata(<<>>, _acc) -> _acc; encode_upload_content_type_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_upload_size(__TopXMLNS, __Opts, {xmlel, <<"size">>, _attrs, _els}) -> Cdata = decode_upload_size_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_upload_size_els(__TopXMLNS, __Opts, [], Cdata) -> decode_upload_size_cdata(__TopXMLNS, Cdata); decode_upload_size_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_upload_size_els(__TopXMLNS, __Opts, _els, <>); decode_upload_size_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_upload_size_els(__TopXMLNS, __Opts, _els, Cdata). encode_upload_size(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = encode_upload_size_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"size">>, _attrs, _els}. decode_upload_size_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"size">>, __TopXMLNS}}); decode_upload_size_cdata(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"size">>, __TopXMLNS}}); _res -> _res end. encode_upload_size_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_upload_filename(__TopXMLNS, __Opts, {xmlel, <<"filename">>, _attrs, _els}) -> Cdata = decode_upload_filename_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_upload_filename_els(__TopXMLNS, __Opts, [], Cdata) -> decode_upload_filename_cdata(__TopXMLNS, Cdata); decode_upload_filename_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_upload_filename_els(__TopXMLNS, __Opts, _els, <>); decode_upload_filename_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_upload_filename_els(__TopXMLNS, __Opts, _els, Cdata). encode_upload_filename(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:http:upload">>, <<"eu:siacs:conversations:http:upload">>], __TopXMLNS), _els = encode_upload_filename_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"filename">>, _attrs, _els}. decode_upload_filename_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"filename">>, __TopXMLNS}}); decode_upload_filename_cdata(__TopXMLNS, _val) -> _val. encode_upload_filename_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0138.erl0000644000232200023220000003406513610066730015467 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0138). -compile(export_all). do_decode(<<"compression">>, <<"http://jabber.org/features/compress">>, El, Opts) -> decode_compression(<<"http://jabber.org/features/compress">>, Opts, El); do_decode(<<"method">>, <<"http://jabber.org/features/compress">>, El, Opts) -> decode_compression_method(<<"http://jabber.org/features/compress">>, Opts, El); do_decode(<<"compressed">>, <<"http://jabber.org/protocol/compress">>, El, Opts) -> decode_compressed(<<"http://jabber.org/protocol/compress">>, Opts, El); do_decode(<<"compress">>, <<"http://jabber.org/protocol/compress">>, El, Opts) -> decode_compress(<<"http://jabber.org/protocol/compress">>, Opts, El); do_decode(<<"method">>, <<"http://jabber.org/protocol/compress">>, El, Opts) -> decode_compress_method(<<"http://jabber.org/protocol/compress">>, Opts, El); do_decode(<<"failure">>, <<"http://jabber.org/protocol/compress">>, El, Opts) -> decode_compress_failure(<<"http://jabber.org/protocol/compress">>, Opts, El); do_decode(<<"unsupported-method">>, <<"http://jabber.org/protocol/compress">>, El, Opts) -> decode_compress_failure_unsupported_method(<<"http://jabber.org/protocol/compress">>, Opts, El); do_decode(<<"processing-failed">>, <<"http://jabber.org/protocol/compress">>, El, Opts) -> decode_compress_failure_processing_failed(<<"http://jabber.org/protocol/compress">>, Opts, El); do_decode(<<"setup-failed">>, <<"http://jabber.org/protocol/compress">>, El, Opts) -> decode_compress_failure_setup_failed(<<"http://jabber.org/protocol/compress">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"compression">>, <<"http://jabber.org/features/compress">>}, {<<"method">>, <<"http://jabber.org/features/compress">>}, {<<"compressed">>, <<"http://jabber.org/protocol/compress">>}, {<<"compress">>, <<"http://jabber.org/protocol/compress">>}, {<<"method">>, <<"http://jabber.org/protocol/compress">>}, {<<"failure">>, <<"http://jabber.org/protocol/compress">>}, {<<"unsupported-method">>, <<"http://jabber.org/protocol/compress">>}, {<<"processing-failed">>, <<"http://jabber.org/protocol/compress">>}, {<<"setup-failed">>, <<"http://jabber.org/protocol/compress">>}]. do_encode({compress_failure, _} = Failure, TopXMLNS) -> encode_compress_failure(Failure, TopXMLNS); do_encode({compress, _} = Compress, TopXMLNS) -> encode_compress(Compress, TopXMLNS); do_encode({compressed} = Compressed, TopXMLNS) -> encode_compressed(Compressed, TopXMLNS); do_encode({compression, _} = Compression, TopXMLNS) -> encode_compression(Compression, TopXMLNS). do_get_name({compress, _}) -> <<"compress">>; do_get_name({compress_failure, _}) -> <<"failure">>; do_get_name({compressed}) -> <<"compressed">>; do_get_name({compression, _}) -> <<"compression">>. do_get_ns({compress, _}) -> <<"http://jabber.org/protocol/compress">>; do_get_ns({compress_failure, _}) -> <<"http://jabber.org/protocol/compress">>; do_get_ns({compressed}) -> <<"http://jabber.org/protocol/compress">>; do_get_ns({compression, _}) -> <<"http://jabber.org/features/compress">>. pp(compress_failure, 1) -> [reason]; pp(compress, 1) -> [methods]; pp(compressed, 0) -> []; pp(compression, 1) -> [methods]; pp(_, _) -> no. records() -> [{compress_failure, 1}, {compress, 1}, {compressed, 0}, {compression, 1}]. decode_compression(__TopXMLNS, __Opts, {xmlel, <<"compression">>, _attrs, _els}) -> Methods = decode_compression_els(__TopXMLNS, __Opts, _els, []), {compression, Methods}. decode_compression_els(__TopXMLNS, __Opts, [], Methods) -> lists:reverse(Methods); decode_compression_els(__TopXMLNS, __Opts, [{xmlel, <<"method">>, _attrs, _} = _el | _els], Methods) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/features/compress">> -> decode_compression_els(__TopXMLNS, __Opts, _els, [decode_compression_method(<<"http://jabber.org/features/compress">>, __Opts, _el) | Methods]); _ -> decode_compression_els(__TopXMLNS, __Opts, _els, Methods) end; decode_compression_els(__TopXMLNS, __Opts, [_ | _els], Methods) -> decode_compression_els(__TopXMLNS, __Opts, _els, Methods). encode_compression({compression, Methods}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/features/compress">>, [], __TopXMLNS), _els = lists:reverse('encode_compression_$methods'(Methods, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"compression">>, _attrs, _els}. 'encode_compression_$methods'([], __TopXMLNS, _acc) -> _acc; 'encode_compression_$methods'([Methods | _els], __TopXMLNS, _acc) -> 'encode_compression_$methods'(_els, __TopXMLNS, [encode_compression_method(Methods, __TopXMLNS) | _acc]). decode_compression_method(__TopXMLNS, __Opts, {xmlel, <<"method">>, _attrs, _els}) -> Cdata = decode_compression_method_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_compression_method_els(__TopXMLNS, __Opts, [], Cdata) -> decode_compression_method_cdata(__TopXMLNS, Cdata); decode_compression_method_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_compression_method_els(__TopXMLNS, __Opts, _els, <>); decode_compression_method_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_compression_method_els(__TopXMLNS, __Opts, _els, Cdata). encode_compression_method(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/features/compress">>, [], __TopXMLNS), _els = encode_compression_method_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"method">>, _attrs, _els}. decode_compression_method_cdata(__TopXMLNS, <<>>) -> <<>>; decode_compression_method_cdata(__TopXMLNS, _val) -> _val. encode_compression_method_cdata(<<>>, _acc) -> _acc; encode_compression_method_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_compressed(__TopXMLNS, __Opts, {xmlel, <<"compressed">>, _attrs, _els}) -> {compressed}. encode_compressed({compressed}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/compress">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"compressed">>, _attrs, _els}. decode_compress(__TopXMLNS, __Opts, {xmlel, <<"compress">>, _attrs, _els}) -> Methods = decode_compress_els(__TopXMLNS, __Opts, _els, []), {compress, Methods}. decode_compress_els(__TopXMLNS, __Opts, [], Methods) -> lists:reverse(Methods); decode_compress_els(__TopXMLNS, __Opts, [{xmlel, <<"method">>, _attrs, _} = _el | _els], Methods) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/compress">> -> decode_compress_els(__TopXMLNS, __Opts, _els, [decode_compress_method(<<"http://jabber.org/protocol/compress">>, __Opts, _el) | Methods]); _ -> decode_compress_els(__TopXMLNS, __Opts, _els, Methods) end; decode_compress_els(__TopXMLNS, __Opts, [_ | _els], Methods) -> decode_compress_els(__TopXMLNS, __Opts, _els, Methods). encode_compress({compress, Methods}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/compress">>, [], __TopXMLNS), _els = lists:reverse('encode_compress_$methods'(Methods, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"compress">>, _attrs, _els}. 'encode_compress_$methods'([], __TopXMLNS, _acc) -> _acc; 'encode_compress_$methods'([Methods | _els], __TopXMLNS, _acc) -> 'encode_compress_$methods'(_els, __TopXMLNS, [encode_compress_method(Methods, __TopXMLNS) | _acc]). decode_compress_method(__TopXMLNS, __Opts, {xmlel, <<"method">>, _attrs, _els}) -> Cdata = decode_compress_method_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_compress_method_els(__TopXMLNS, __Opts, [], Cdata) -> decode_compress_method_cdata(__TopXMLNS, Cdata); decode_compress_method_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_compress_method_els(__TopXMLNS, __Opts, _els, <>); decode_compress_method_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_compress_method_els(__TopXMLNS, __Opts, _els, Cdata). encode_compress_method(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/compress">>, [], __TopXMLNS), _els = encode_compress_method_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"method">>, _attrs, _els}. decode_compress_method_cdata(__TopXMLNS, <<>>) -> <<>>; decode_compress_method_cdata(__TopXMLNS, _val) -> _val. encode_compress_method_cdata(<<>>, _acc) -> _acc; encode_compress_method_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_compress_failure(__TopXMLNS, __Opts, {xmlel, <<"failure">>, _attrs, _els}) -> Reason = decode_compress_failure_els(__TopXMLNS, __Opts, _els, undefined), {compress_failure, Reason}. decode_compress_failure_els(__TopXMLNS, __Opts, [], Reason) -> Reason; decode_compress_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"setup-failed">>, _attrs, _} = _el | _els], Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/compress">> -> decode_compress_failure_els(__TopXMLNS, __Opts, _els, decode_compress_failure_setup_failed(<<"http://jabber.org/protocol/compress">>, __Opts, _el)); _ -> decode_compress_failure_els(__TopXMLNS, __Opts, _els, Reason) end; decode_compress_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"processing-failed">>, _attrs, _} = _el | _els], Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/compress">> -> decode_compress_failure_els(__TopXMLNS, __Opts, _els, decode_compress_failure_processing_failed(<<"http://jabber.org/protocol/compress">>, __Opts, _el)); _ -> decode_compress_failure_els(__TopXMLNS, __Opts, _els, Reason) end; decode_compress_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"unsupported-method">>, _attrs, _} = _el | _els], Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/compress">> -> decode_compress_failure_els(__TopXMLNS, __Opts, _els, decode_compress_failure_unsupported_method(<<"http://jabber.org/protocol/compress">>, __Opts, _el)); _ -> decode_compress_failure_els(__TopXMLNS, __Opts, _els, Reason) end; decode_compress_failure_els(__TopXMLNS, __Opts, [_ | _els], Reason) -> decode_compress_failure_els(__TopXMLNS, __Opts, _els, Reason). encode_compress_failure({compress_failure, Reason}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/compress">>, [], __TopXMLNS), _els = lists:reverse('encode_compress_failure_$reason'(Reason, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"failure">>, _attrs, _els}. 'encode_compress_failure_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_compress_failure_$reason'('setup-failed' = Reason, __TopXMLNS, _acc) -> [encode_compress_failure_setup_failed(Reason, __TopXMLNS) | _acc]; 'encode_compress_failure_$reason'('processing-failed' = Reason, __TopXMLNS, _acc) -> [encode_compress_failure_processing_failed(Reason, __TopXMLNS) | _acc]; 'encode_compress_failure_$reason'('unsupported-method' = Reason, __TopXMLNS, _acc) -> [encode_compress_failure_unsupported_method(Reason, __TopXMLNS) | _acc]. decode_compress_failure_unsupported_method(__TopXMLNS, __Opts, {xmlel, <<"unsupported-method">>, _attrs, _els}) -> 'unsupported-method'. encode_compress_failure_unsupported_method('unsupported-method', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/compress">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-method">>, _attrs, _els}. decode_compress_failure_processing_failed(__TopXMLNS, __Opts, {xmlel, <<"processing-failed">>, _attrs, _els}) -> 'processing-failed'. encode_compress_failure_processing_failed('processing-failed', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/compress">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"processing-failed">>, _attrs, _els}. decode_compress_failure_setup_failed(__TopXMLNS, __Opts, {xmlel, <<"setup-failed">>, _attrs, _els}) -> 'setup-failed'. encode_compress_failure_setup_failed('setup-failed', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/compress">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"setup-failed">>, _attrs, _els}. xmpp-1.4.4/src/xmpp.erl0000644000232200023220000011635413610066730015345 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% %%% @end %%% Created : 9 Dec 2015 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp). -behaviour(application). -dialyzer({nowarn_function, get_els/1}). %% API %% Application callbacks -export([start/2, stop/1]). -export([make_iq_result/1, make_iq_result/2, make_error/2, decode/1, decode/3, encode/1, encode/2, get_type/1, get_to/1, get_from/1, get_id/1, get_lang/1, get_error/1, get_els/1, get_ns/1, get_meta/1, get_meta/2, get_meta/3, set_type/2, set_to/2, set_from/2, set_id/2, set_lang/2, set_error/2, set_els/2, set_from_to/3, set_meta/2, put_meta/3, update_meta/3, del_meta/2, format_error/1, io_format_error/1, is_stanza/1, try_subtag/2, set_subtag/2, get_subtag/2, remove_subtag/2, has_subtag/2, decode_els/1, decode_els/3, pp/1, get_name/1, get_text/1, get_text/2, mk_text/1, mk_text/2, is_known_tag/1, is_known_tag/2, append_subtags/2, prep_lang/1, register_codec/1, unregister_codec/1, set_tr_callback/1, format_stanza_error/1, format_stanza_error/2, format_stream_error/1, format_stream_error/2, format_sasl_error/1, format_sasl_error/2, set_config/1, get_config/0, get_subtags/2, try_subtags/2]). %% XMPP errors -export([err_bad_request/0, err_bad_request/2, err_conflict/0, err_conflict/2, err_feature_not_implemented/0, err_feature_not_implemented/2, err_forbidden/0, err_forbidden/2, err_gone/1, err_gone/3, err_internal_server_error/0, err_internal_server_error/2, err_item_not_found/0, err_item_not_found/2, err_jid_malformed/0, err_jid_malformed/2, err_not_acceptable/0, err_not_acceptable/2, err_not_allowed/0, err_not_allowed/2, err_not_authorized/0, err_not_authorized/2, err_payment_required/0, err_payment_required/2, err_policy_violation/0, err_policy_violation/2, err_recipient_unavailable/0, err_recipient_unavailable/2, err_redirect/1, err_redirect/3, err_registration_required/0, err_registration_required/2, err_remote_server_not_found/0, err_remote_server_not_found/2, err_remote_server_timeout/0, err_remote_server_timeout/2, err_resource_constraint/0, err_resource_constraint/2, err_service_unavailable/0, err_service_unavailable/2, err_subscription_required/0, err_subscription_required/2, err_undefined_condition/1, err_undefined_condition/3, err_unexpected_request/0, err_unexpected_request/2]). %% XMPP stream errors -export([serr_bad_format/0, serr_bad_format/2, serr_bad_namespace_prefix/0, serr_bad_namespace_prefix/2, serr_conflict/0, serr_conflict/2, serr_connection_timeout/0, serr_connection_timeout/2, serr_host_gone/0, serr_host_gone/2, serr_host_unknown/0, serr_host_unknown/2, serr_improper_addressing/0, serr_improper_addressing/2, serr_internal_server_error/0, serr_internal_server_error/2, serr_invalid_from/0, serr_invalid_from/2, serr_invalid_id/0, serr_invalid_id/2, serr_invalid_namespace/0, serr_invalid_namespace/2, serr_invalid_xml/0, serr_invalid_xml/2, serr_not_authorized/0, serr_not_authorized/2, serr_not_well_formed/0, serr_not_well_formed/2, serr_policy_violation/0, serr_policy_violation/2, serr_remote_connection_failed/0, serr_remote_connection_failed/2, serr_reset/0, serr_reset/2, serr_resource_constraint/0, serr_resource_constraint/2, serr_restricted_xml/0, serr_restricted_xml/2, serr_see_other_host/1, serr_see_other_host/3, serr_system_shutdown/0, serr_system_shutdown/2, serr_undefined_condition/0, serr_undefined_condition/2, serr_unsupported_encoding/0, serr_unsupported_encoding/2, serr_unsupported_feature/0, serr_unsupported_feature/2, serr_unsupported_stanza_type/0, serr_unsupported_stanza_type/2, serr_unsupported_version/0, serr_unsupported_version/2]). -include("xmpp.hrl"). -type reason_text() :: binary() | {io:format(), list()}. -type lang() :: binary(). -type decode_option() :: ignore_els. -type config_option() :: {debug, boolean()} | {fqdn, [binary()]}. -export_type([decode_option/0, config_option/0]). %%%=================================================================== %%% Application callbacks %%%=================================================================== start(_StartType, _StartArgs) -> try {ok, _} = application:ensure_all_started(fast_xml), {ok, _} = application:ensure_all_started(stringprep), {ok, _} = application:ensure_all_started(fast_tls), {ok, _} = application:ensure_all_started(ezlib), ok = jid:start(), ok = xmpp_uri:start(), ok = xmpp_lang:start(), p1_options:start_link(xmpp_config), p1_options:insert(xmpp_config, debug, global, false), p1_options:insert(xmpp_config, fqdn, global, []), xmpp_sup:start_link() catch _:{badmatch, Err} -> Err end. stop(_State) -> ok. %%%=================================================================== %%% API %%%=================================================================== -spec make_iq_result(iq()) -> iq(). make_iq_result(IQ) -> make_iq_result(IQ, undefined). -spec make_iq_result(iq(), xmpp_element() | xmlel() | undefined) -> iq(). make_iq_result(#iq{type = Type, from = From, to = To} = IQ, El) when Type == get; Type == set -> SubEls = if El == undefined -> []; true -> [El] end, IQ#iq{type = result, to = From, from = To, sub_els = SubEls}. -spec make_error(message(), stanza_error() | xmlel()) -> message(); (presence(), stanza_error() | xmlel()) -> presence(); (iq(), stanza_error() | xmlel()) -> iq(); (xmlel(), stanza_error() | xmlel()) -> xmlel(). make_error(#message{type = Type, from = From, to = To, sub_els = Els} = Msg, Err) when Type /= error -> Msg#message{type = error, from = To, to = From, sub_els = Els ++ [Err]}; make_error(#presence{type = Type, from = From, to = To, sub_els = Els} = Pres, Err) when Type /= error -> Pres#presence{type = error, from = To, to = From, sub_els = Els ++ [Err]}; make_error(#iq{type = Type, from = From, to = To, sub_els = Els} = IQ, Err) when Type /= result, Type /= error -> IQ#iq{type = error, from = To, to = From, sub_els = Els ++ [Err]}; make_error(#xmlel{attrs = Attrs, children = Els} = El, Err) -> To = fxml:get_attr(<<"to">>, Attrs), From = fxml:get_attr(<<"from">>, Attrs), Attrs1 = case To of {value, T} -> lists:keystore(<<"from">>, 1, Attrs, {<<"from">>, T}); _ -> lists:keydelete(<<"from">>, 1, Attrs) end, Attrs2 = case From of {value, F} -> lists:keystore(<<"to">>, 1, Attrs1, {<<"to">>, F}); _ -> lists:keydelete(<<"to">>, 1, Attrs1) end, Attrs3 = lists:keystore(<<"type">>, 1, Attrs2, {<<"type">>, <<"error">>}), El#xmlel{attrs = Attrs3, children = Els ++ [encode(Err, ?NS_CLIENT)]}. -spec get_id(stanza() | xmlel()) -> binary(). get_id(#iq{id = ID}) -> ID; get_id(#message{id = ID}) -> ID; get_id(#presence{id = ID}) -> ID; get_id(#xmlel{attrs = Attrs}) -> fxml:get_attr_s(<<"id">>, Attrs). -spec get_type(iq()) -> iq_type(); (message()) -> message_type(); (presence()) -> presence_type(); (xmlel()) -> binary(). get_type(#iq{type = T}) -> T; get_type(#message{type = T}) -> T; get_type(#presence{type = T}) -> T; get_type(#xmlel{attrs = Attrs}) -> fxml:get_attr_s(<<"type">>, Attrs). -spec get_lang(stanza() | xmlel()) -> binary(). get_lang(#iq{lang = L}) -> L; get_lang(#message{lang = L}) -> L; get_lang(#presence{lang = L}) -> L; get_lang(#xmlel{attrs = Attrs}) -> fxml:get_attr_s(<<"xml:lang">>, Attrs). -spec get_from(stanza()) -> undefined | jid:jid(). get_from(#iq{from = J}) -> J; get_from(#message{from = J}) -> J; get_from(#presence{from = J}) -> J. -spec get_to(stanza()) -> undefined | jid:jid(). get_to(#iq{to = J}) -> J; get_to(#message{to = J}) -> J; get_to(#presence{to = J}) -> J. -spec get_error(xmpp_element()) -> undefined | stanza_error(). get_error(Pkt) -> case get_subtag(Pkt, #stanza_error{type = cancel}) of false -> undefined; Error -> Error end. -spec get_els(xmpp_element()) -> [xmpp_element() | xmlel()]; (xmlel()) -> [xmlel()]. get_els(#xmlel{children = Els}) -> [El || El = #xmlel{} <- Els]; get_els(Pkt) -> xmpp_codec:get_els(Pkt). -spec set_id(iq(), binary()) -> iq(); (message(), binary()) -> message(); (presence(), binary()) -> presence(). set_id(#iq{} = IQ, I) -> IQ#iq{id = I}; set_id(#message{} = Msg, I) -> Msg#message{id = I}; set_id(#presence{} = Pres, I) -> Pres#presence{id = I}. -spec set_type(iq(), iq_type()) -> iq(); (message(), message_type()) -> message(); (presence(), presence_type()) -> presence(). set_type(#iq{} = IQ, T) -> IQ#iq{type = T}; set_type(#message{} = Msg, T) -> Msg#message{type = T}; set_type(#presence{} = Pres, T) -> Pres#presence{type = T}. -spec set_lang(iq(), binary()) -> iq(); (message(), binary()) -> message(); (presence(), binary()) -> presence(). set_lang(#iq{} = IQ, L) -> IQ#iq{lang = L}; set_lang(#message{} = Msg, L) -> Msg#message{lang = L}; set_lang(#presence{} = Pres, L) -> Pres#presence{lang = L}. -spec set_from(iq(), jid:jid() | undefined) -> iq(); (message(), jid:jid() | undefined) -> message(); (presence(), jid:jid() | undefined) -> presence(). set_from(#iq{} = IQ, J) -> IQ#iq{from = J}; set_from(#message{} = Msg, J) -> Msg#message{from = J}; set_from(#presence{} = Pres, J) -> Pres#presence{from = J}. -spec set_to(iq(), jid:jid() | undefined) -> iq(); (message(), jid:jid() | undefined) -> message(); (presence(), jid:jid() | undefined) -> presence(). set_to(#iq{} = IQ, J) -> IQ#iq{to = J}; set_to(#message{} = Msg, J) -> Msg#message{to = J}; set_to(#presence{} = Pres, J) -> Pres#presence{to = J}. -spec set_from_to(iq(), undefined | jid:jid(), undefined | jid:jid()) -> iq(); (message(), undefined | jid:jid(), undefined | jid:jid()) -> message(); (presence(), undefined | jid:jid(), undefined | jid:jid()) -> presence(). set_from_to(#iq{} = IQ, F, T) -> IQ#iq{from = F, to = T}; set_from_to(#message{} = Msg, F, T) -> Msg#message{from = F, to = T}; set_from_to(#presence{} = Pres, F, T) -> Pres#presence{from = F, to = T}. -spec set_error(iq(), stanza_error()) -> iq(); (message(), stanza_error()) -> message(); (presence(), stanza_error()) -> presence(). set_error(Stanza, E) -> set_subtag(Stanza, E). -spec set_els(xmpp_element(), [xmpp_element() | xmlel()]) -> xmpp_element(). set_els(Pkt, Els) -> xmpp_codec:set_els(Pkt, Els). -spec get_ns(xmpp_element() | xmlel()) -> binary(). get_ns(#xmlel{attrs = Attrs}) -> fxml:get_attr_s(<<"xmlns">>, Attrs); get_ns(Pkt) -> xmpp_codec:get_ns(Pkt). -spec get_name(xmpp_element() | xmlel()) -> binary(). get_name(#xmlel{name = Name}) -> Name; get_name(Pkt) -> xmpp_codec:get_name(Pkt). -spec get_meta(stanza()) -> map(). get_meta(#iq{meta = M}) -> M; get_meta(#message{meta = M}) -> M; get_meta(#presence{meta = M}) -> M. -spec get_meta(stanza(), any()) -> any(). get_meta(#iq{meta = M}, K) -> maps:get(K, M); get_meta(#message{meta = M}, K) -> maps:get(K, M); get_meta(#presence{meta = M}, K) -> maps:get(K, M). -spec get_meta(stanza(), any(), any()) -> any(). get_meta(#iq{meta = M}, K, Def) -> maps:get(K, M, Def); get_meta(#message{meta = M}, K, Def) -> maps:get(K, M, Def); get_meta(#presence{meta = M}, K, Def) -> maps:get(K, M, Def). -spec set_meta(iq(), map()) -> iq(); (message(), map()) -> message(); (presence(), map()) -> presence(). set_meta(#iq{} = IQ, M) -> IQ#iq{meta = M}; set_meta(#message{} = Msg, M) -> Msg#message{meta = M}; set_meta(#presence{} = Pres, M) -> Pres#presence{meta = M}. -spec put_meta(iq(), any(), any()) -> iq(); (message(), any(), any()) -> message(); (presence(), any(), any()) -> presence(). put_meta(#iq{meta = M} = IQ, K, V) -> IQ#iq{meta = maps:put(K, V, M)}; put_meta(#message{meta = M} = Msg, K, V) -> Msg#message{meta = maps:put(K, V, M)}; put_meta(#presence{meta = M} = Pres, K, V) -> Pres#presence{meta = maps:put(K, V, M)}. -spec update_meta(iq(), any(), any()) -> iq(); (message(), any(), any()) -> message(); (presence(), any(), any()) -> presence(). update_meta(#iq{meta = M} = IQ, K, V) -> IQ#iq{meta = maps:update(K, V, M)}; update_meta(#message{meta = M} = Msg, K, V) -> Msg#message{meta = maps:update(K, V, M)}; update_meta(#presence{meta = M} = Pres, K, V) -> Pres#presence{meta = maps:update(K, V, M)}. -spec del_meta(iq(), any()) -> iq(); (message(), any()) -> message(); (presence(), any()) -> presence(). del_meta(#iq{meta = M} = IQ, K) -> IQ#iq{meta = maps:remove(K, M)}; del_meta(#message{meta = M} = Msg, K) -> Msg#message{meta = maps:remove(K, M)}; del_meta(#presence{meta = M} = Pres, K) -> Pres#presence{meta = maps:remove(K, M)}. -spec decode(xmlel() | xmpp_element()) -> xmpp_element(). decode(El) -> decode(El, ?NS_CLIENT, []). -spec decode(xmlel() | xmpp_element(), binary(), [decode_option()]) -> xmpp_element(). decode(#xmlel{} = El, TopXMLNS, Opts) -> xmpp_codec:decode(El, TopXMLNS, Opts); decode(Pkt, _, _) -> Pkt. -spec decode_els(xmpp_element()) -> xmpp_element(). decode_els(Pkt) -> decode_els(Pkt, ?NS_CLIENT, fun is_known_tag/1). -type match_fun() :: fun((xmlel()) -> boolean()). -spec decode_els(xmpp_element(), binary(), match_fun()) -> xmpp_element(). decode_els(Pkt, TopXMLNS, MatchFun) -> Els = lists:map( fun(#xmlel{} = El) -> case MatchFun(El) of true -> decode(El, TopXMLNS, []); false -> El end; (El) -> El end, get_els(Pkt)), set_els(Pkt, Els). -spec encode(xmpp_element() | xmlel()) -> xmlel(). encode(Pkt) -> encode(Pkt, <<>>). -spec encode(xmpp_element() | xmlel(), binary()) -> xmlel(). encode(Pkt, TopXMLNS) -> xmpp_codec:encode(Pkt, TopXMLNS). -spec is_known_tag(xmlel()) -> boolean(). is_known_tag(El) -> is_known_tag(El, ?NS_CLIENT). -spec is_known_tag(xmlel(), binary()) -> boolean(). is_known_tag(El, TopXMLNS) -> xmpp_codec:is_known_tag(El, TopXMLNS). -spec format_error(_) -> binary(). format_error(Reason) -> xmpp_codec:format_error(Reason). -spec io_format_error(_) -> {binary(), [binary()]}. io_format_error(Reason) -> xmpp_codec:io_format_error(Reason). -spec format_stanza_error(stanza_error()) -> binary(). format_stanza_error(Err) -> format_stanza_error(Err, <<"en">>). -spec format_stanza_error(stanza_error(), binary()) -> binary(). format_stanza_error(#stanza_error{reason = Reason, text = Text}, Lang) -> format_s_error(Reason, Text, Lang). -spec format_stream_error(stream_error()) -> binary(). format_stream_error(Err) -> format_stream_error(Err, <<"en">>). -spec format_stream_error(stream_error(), binary()) -> binary(). format_stream_error(#stream_error{reason = Reason, text = Text}, Lang) -> format_s_error(Reason, Text, Lang). -spec format_sasl_error(sasl_failure()) -> binary(). format_sasl_error(Err) -> format_sasl_error(Err, <<"en">>). -spec format_sasl_error(sasl_failure(), binary()) -> binary(). format_sasl_error(#sasl_failure{reason = Reason, text = Text}, Lang) -> format_s_error(Reason, Text, Lang). -spec is_stanza(any()) -> boolean(). is_stanza(#message{}) -> true; is_stanza(#iq{}) -> true; is_stanza(#presence{}) -> true; is_stanza(#xmlel{name = Name}) -> (Name == <<"iq">>) or (Name == <<"message">>) or (Name == <<"presence">>); is_stanza(_) -> false. -spec set_subtag(xmpp_element(), xmpp_element()) -> xmpp_element(). set_subtag(Pkt, Tag) -> TagName = xmpp_codec:get_name(Tag), TopXMLNS = xmpp_codec:get_ns(Pkt), XMLNS = xmpp_codec:get_ns(Tag), Els = get_els(Pkt), NewEls = set_subtag(Els, Tag, TagName, XMLNS, TopXMLNS), set_els(Pkt, NewEls). set_subtag([El|Els], Tag, TagName, XMLNS, TopXMLNS) -> case match_tag(El, TagName, XMLNS, TopXMLNS) of true -> [Tag|Els]; false -> [El|set_subtag(Els, Tag, TagName, XMLNS, TopXMLNS)] end; set_subtag([], Tag, _, _, _) -> [Tag]. -spec get_subtag(xmpp_element(), xmpp_element()) -> xmpp_element() | false. get_subtag(Pkt, Tag) -> Els = get_els(Pkt), TopXMLNS = xmpp_codec:get_ns(Pkt), TagName = xmpp_codec:get_name(Tag), XMLNS = xmpp_codec:get_ns(Tag), get_subtag(Els, TagName, XMLNS, TopXMLNS). get_subtag([El|Els], TagName, XMLNS, TopXMLNS) -> case match_tag(El, TagName, XMLNS, TopXMLNS) of true -> try decode(El) catch _:{xmpp_codec, _Why} -> get_subtag(Els, TagName, XMLNS, TopXMLNS) end; false -> get_subtag(Els, TagName, XMLNS, TopXMLNS) end; get_subtag([], _, _, _) -> false. -spec get_subtags(xmpp_element(), xmpp_element()) -> [xmpp_element()]. get_subtags(Pkt, Tag) -> Els = get_els(Pkt), TopXMLNS = xmpp_codec:get_ns(Pkt), TagName = xmpp_codec:get_name(Tag), XMLNS = xmpp_codec:get_ns(Tag), get_subtags(Els, TagName, XMLNS, TopXMLNS, []). get_subtags([El|Els], TagName, XMLNS, TopXMLNS, Acc) -> case match_tag(El, TagName, XMLNS, TopXMLNS) of true -> try get_subtags(Els, TagName, XMLNS, TopXMLNS, [decode(El) | Acc]) catch _:{xmpp_codec, _Why} -> get_subtags(Els, TagName, XMLNS, TopXMLNS, Acc) end; false -> get_subtags(Els, TagName, XMLNS, TopXMLNS, Acc) end; get_subtags([], _, _, _, Acc) -> lists:reverse(Acc). -spec try_subtag(xmpp_element(), xmpp_element()) -> xmpp_element() | false. try_subtag(Pkt, Tag) -> Els = get_els(Pkt), TopXMLNS = xmpp_codec:get_ns(Pkt), TagName = xmpp_codec:get_name(Tag), XMLNS = xmpp_codec:get_ns(Tag), try_subtag(Els, TagName, XMLNS, TopXMLNS). try_subtag([El|Els], TagName, XMLNS, TopXMLNS) -> case match_tag(El, TagName, XMLNS, TopXMLNS) of true -> decode(El); false -> try_subtag(Els, TagName, XMLNS, TopXMLNS) end; try_subtag([], _, _, _) -> false. -spec try_subtags(xmpp_element(), xmpp_element()) -> [xmpp_element()]. try_subtags(Pkt, Tag) -> Els = get_els(Pkt), TopXMLNS = xmpp_codec:get_ns(Pkt), TagName = xmpp_codec:get_name(Tag), XMLNS = xmpp_codec:get_ns(Tag), try_subtags(Els, TagName, XMLNS, TopXMLNS, []). try_subtags([El|Els], TagName, XMLNS, TopXMLNS, Acc) -> case match_tag(El, TagName, XMLNS, TopXMLNS) of true -> try_subtags(Els, TagName, XMLNS, TopXMLNS, [decode(El) | Acc]); false -> try_subtags(Els, TagName, XMLNS, TopXMLNS, Acc) end; try_subtags([], _, _, _, Acc) -> lists:reverse(Acc). -spec remove_subtag(xmpp_element(), xmpp_element()) -> xmpp_element(). remove_subtag(Pkt, Tag) -> Els = get_els(Pkt), TagName = xmpp_codec:get_name(Tag), TopXMLNS = xmpp_codec:get_ns(Pkt), XMLNS = xmpp_codec:get_ns(Tag), NewEls = remove_subtag(Els, TagName, XMLNS, TopXMLNS), set_els(Pkt, NewEls). remove_subtag([El|Els], TagName, XMLNS, TopXMLNS) -> case match_tag(El, TagName, XMLNS, TopXMLNS) of true -> remove_subtag(Els, TagName, XMLNS, TopXMLNS); false -> [El|remove_subtag(Els, TagName, XMLNS, TopXMLNS)] end; remove_subtag([], _, _, _) -> []. -spec has_subtag(xmpp_element(), xmpp_element()) -> boolean(). has_subtag(Pkt, Tag) -> Els = get_els(Pkt), TagName = xmpp_codec:get_name(Tag), TopXMLNS = xmpp_codec:get_ns(Pkt), XMLNS = xmpp_codec:get_ns(Tag), has_subtag(Els, TagName, XMLNS, TopXMLNS). has_subtag([El|Els], TagName, XMLNS, TopXMLNS) -> case match_tag(El, TagName, XMLNS, TopXMLNS) of true -> true; false -> has_subtag(Els, TagName, XMLNS, TopXMLNS) end; has_subtag([], _, _, _) -> false. -spec append_subtags(xmpp_element(), [xmpp_element() | xmlel()]) -> xmpp_element(). append_subtags(Pkt, Tags) -> Els = get_els(Pkt), set_els(Pkt, Els ++ Tags). -spec get_text([text()]) -> binary(). get_text(Text) -> get_text(Text, <<"en">>). -spec get_text([text()], binary()) -> binary(). get_text(Text, Lang) -> get_text(Text, Lang, <<>>). -spec mk_text(reason_text()) -> [text()]. mk_text(Text) -> mk_text(Text, <<"">>). -spec mk_text(reason_text(), lang()) -> [text()]. mk_text(<<"">>, _Lang) -> []; mk_text({Format, Args}, Lang) -> InFormat = iolist_to_binary(Format), OutFormat = xmpp_tr:tr(Lang, InFormat), InTxt = iolist_to_binary(io_lib:format(InFormat, Args)), if InFormat == OutFormat -> [#text{data = InTxt, lang = <<"en">>}]; true -> OutTxt = iolist_to_binary(io_lib:format(OutFormat, Args)), [#text{data = OutTxt, lang = Lang}, #text{data = InTxt, lang = <<"en">>}] end; mk_text(InTxt, Lang) -> OutTxt = xmpp_tr:tr(Lang, InTxt), if OutTxt == InTxt -> [#text{data = InTxt, lang = <<"en">>}]; true -> [#text{data = OutTxt, lang = Lang}, #text{data = InTxt, lang = <<"en">>}] end. -spec pp(any()) -> iodata(). pp(Term) -> io_lib_pretty:print(Term, fun pp/2). -spec register_codec(module()) -> ok. register_codec(Mod) -> xmpp_codec:register_module(Mod). -spec unregister_codec(module()) -> ok. unregister_codec(Mod) -> xmpp_codec:unregister_module(Mod). -spec set_tr_callback({module(), atom()} | undefined) -> ok. set_tr_callback(Callback) -> Forms = get_tr_forms(Callback), {ok, Code} = case compile:forms(Forms, []) of {ok, xmpp_tr, Bin} -> {ok, Bin}; {ok, xmpp_tr, Bin, _Warnings} -> {ok, Bin}; Error -> Error end, {module, xmpp_tr} = code:load_binary(xmpp_tr, "nofile", Code), ok. -spec set_config([config_option()]) -> ok. set_config(Options) -> lists:foreach( fun({debug, Bool}) when is_boolean(Bool) -> p1_options:insert(xmpp_config, debug, global, Bool); ({fqdn, Domains}) -> case lists:all(fun erlang:is_binary/1, Domains) of true -> p1_options:insert(xmpp_config, fqdn, global, Domains); false -> erlang:error(badarg) end; (_) -> erlang:error(badarg) end, Options), p1_options:compile(xmpp_config). -spec get_config() -> [config_option()]. get_config() -> {ok, Debug} = xmpp_config:debug(global), {ok, Domains} = xmpp_config:fqdn(global), [{debug, Debug}, {fqdn, Domains}]. %%%=================================================================== %%% Functions to construct general XMPP errors %%%=================================================================== -spec err_bad_request() -> stanza_error(). err_bad_request() -> err(modify, 'bad-request', 400). -spec err_bad_request(reason_text(), lang()) -> stanza_error(). err_bad_request(Text, Lang) -> err(modify, 'bad-request', 400, Text, Lang). -spec err_conflict() -> stanza_error(). err_conflict() -> err(cancel, 'conflict', 409). -spec err_conflict(reason_text(), lang()) -> stanza_error(). err_conflict(Text, Lang) -> err(cancel, 'conflict', 409, Text, Lang). -spec err_feature_not_implemented() -> stanza_error(). err_feature_not_implemented() -> err(cancel, 'feature-not-implemented', 501). -spec err_feature_not_implemented(reason_text(), lang()) -> stanza_error(). err_feature_not_implemented(Text, Lang) -> err(cancel, 'feature-not-implemented', 501, Text, Lang). -spec err_forbidden() -> stanza_error(). err_forbidden() -> err(auth, 'forbidden', 403). -spec err_forbidden(reason_text(), lang()) -> stanza_error(). err_forbidden(Text, Lang) -> err(auth, 'forbidden', 403, Text, Lang). %% RFC 6120 says error type SHOULD be "cancel". %% RFC 3920 and XEP-0082 says it SHOULD be "modify". -spec err_gone(binary()) -> stanza_error(). err_gone(URI) -> err(modify, #gone{uri = URI}, 302). -spec err_gone(binary(), reason_text(), lang()) -> stanza_error(). err_gone(URI, Text, Lang) -> err(modify, #gone{uri = URI}, 302, Text, Lang). %% RFC 6120 says error type SHOULD be "cancel". %% RFC 3920 and XEP-0082 says it SHOULD be "wait". -spec err_internal_server_error() -> stanza_error(). err_internal_server_error() -> err(wait, 'internal-server-error', 500). -spec err_internal_server_error(reason_text(), lang()) -> stanza_error(). err_internal_server_error(Text, Lang) -> err(wait, 'internal-server-error', 500, Text, Lang). -spec err_item_not_found() -> stanza_error(). err_item_not_found() -> err(cancel, 'item-not-found', 404). -spec err_item_not_found(reason_text(), lang()) -> stanza_error(). err_item_not_found(Text, Lang) -> err(cancel, 'item-not-found', 404, Text, Lang). -spec err_jid_malformed() -> stanza_error(). err_jid_malformed() -> err(modify, 'jid-malformed', 400). -spec err_jid_malformed(reason_text(), lang()) -> stanza_error(). err_jid_malformed(Text, Lang) -> err(modify, 'jid-malformed', 400, Text, Lang). -spec err_not_acceptable() -> stanza_error(). err_not_acceptable() -> err(modify, 'not-acceptable', 406). -spec err_not_acceptable(reason_text(), lang()) -> stanza_error(). err_not_acceptable(Text, Lang) -> err(modify, 'not-acceptable', 406, Text, Lang). -spec err_not_allowed() -> stanza_error(). err_not_allowed() -> err(cancel, 'not-allowed', 405). -spec err_not_allowed(reason_text(), lang()) -> stanza_error(). err_not_allowed(Text, Lang) -> err(cancel, 'not-allowed', 405, Text, Lang). -spec err_not_authorized() -> stanza_error(). err_not_authorized() -> err(auth, 'not-authorized', 401). -spec err_not_authorized(reason_text(), lang()) -> stanza_error(). err_not_authorized(Text, Lang) -> err(auth, 'not-authorized', 401, Text, Lang). -spec err_payment_required() -> stanza_error(). err_payment_required() -> err(auth, 'not-authorized', 402). -spec err_payment_required(reason_text(), lang()) -> stanza_error(). err_payment_required(Text, Lang) -> err(auth, 'not-authorized', 402, Text, Lang). %% is defined in neither RFC 3920 nor XEP-0086. %% We choose '403' error code (as in ). -spec err_policy_violation() -> stanza_error(). err_policy_violation() -> err(modify, 'policy-violation', 403). -spec err_policy_violation(reason_text(), lang()) -> stanza_error(). err_policy_violation(Text, Lang) -> err(modify, 'policy-violation', 403, Text, Lang). -spec err_recipient_unavailable() -> stanza_error(). err_recipient_unavailable() -> err(wait, 'recipient-unavailable', 404). -spec err_recipient_unavailable(reason_text(), lang()) -> stanza_error(). err_recipient_unavailable(Text, Lang) -> err(wait, 'recipient-unavailable', 404, Text, Lang). -spec err_redirect(binary()) -> stanza_error(). err_redirect(URI) -> err(modify, #redirect{uri = URI}, 302). -spec err_redirect(binary(), reason_text(), lang()) -> stanza_error(). err_redirect(URI, Text, Lang) -> err(modify, #redirect{uri = URI}, 302, Text, Lang). -spec err_registration_required() -> stanza_error(). err_registration_required() -> err(auth, 'registration-required', 407). -spec err_registration_required(reason_text(), lang()) -> stanza_error(). err_registration_required(Text, Lang) -> err(auth, 'registration-required', 407, Text, Lang). -spec err_remote_server_not_found() -> stanza_error(). err_remote_server_not_found() -> err(cancel, 'remote-server-not-found', 404). -spec err_remote_server_not_found(reason_text(), lang()) -> stanza_error(). err_remote_server_not_found(Text, Lang) -> err(cancel, 'remote-server-not-found', 404, Text, Lang). -spec err_remote_server_timeout() -> stanza_error(). err_remote_server_timeout() -> err(wait, 'remote-server-timeout', 504). -spec err_remote_server_timeout(reason_text(), lang()) -> stanza_error(). err_remote_server_timeout(Text, Lang) -> err(wait, 'remote-server-timeout', 504, Text, Lang). -spec err_resource_constraint() -> stanza_error(). err_resource_constraint() -> err(wait, 'resource-constraint', 500). -spec err_resource_constraint(reason_text(), lang()) -> stanza_error(). err_resource_constraint(Text, Lang) -> err(wait, 'resource-constraint', 500, Text, Lang). -spec err_service_unavailable() -> stanza_error(). err_service_unavailable() -> err(cancel, 'service-unavailable', 503). -spec err_service_unavailable(reason_text(), lang()) -> stanza_error(). err_service_unavailable(Text, Lang) -> err(cancel, 'service-unavailable', 503, Text, Lang). -spec err_subscription_required() -> stanza_error(). err_subscription_required() -> err(auth, 'subscription-required', 407). -spec err_subscription_required(reason_text(), lang()) -> stanza_error(). err_subscription_required(Text, Lang) -> err(auth, 'subscription-required', 407, Text, Lang). %% No error type is defined for . %% Let user provide the type. -spec err_undefined_condition('auth' | 'cancel' | 'continue' | 'modify' | 'wait') -> stanza_error(). err_undefined_condition(Type) -> err(Type, 'undefined-condition', 500). -spec err_undefined_condition('auth' | 'cancel' | 'continue' | 'modify' | 'wait', reason_text(), lang()) -> stanza_error(). err_undefined_condition(Type, Text, Lang) -> err(Type, 'undefined-condition', 500, Text, Lang). %% RFC 6120 says error type SHOULD be "wait" or "modify". %% RFC 3920 and XEP-0082 says it SHOULD be "wait". -spec err_unexpected_request() -> stanza_error(). err_unexpected_request() -> err(wait, 'unexpected-request', 400). -spec err_unexpected_request(reason_text(), lang()) -> stanza_error(). err_unexpected_request(Text, Lang) -> err(wait, 'unexpected-request', 400, Text, Lang). %%%=================================================================== %%% Functions to construct stream errors %%%=================================================================== -spec serr_bad_format() -> stream_error(). serr_bad_format() -> serr('bad-format'). -spec serr_bad_format(reason_text(), lang()) -> stream_error(). serr_bad_format(Text, Lang) -> serr('bad-format', Text, Lang). -spec serr_bad_namespace_prefix() -> stream_error(). serr_bad_namespace_prefix() -> serr('bad-namespace-prefix'). -spec serr_bad_namespace_prefix(reason_text(), lang()) -> stream_error(). serr_bad_namespace_prefix(Text, Lang) -> serr('bad-namespace-prefix', Text, Lang). -spec serr_conflict() -> stream_error(). serr_conflict() -> serr('conflict'). -spec serr_conflict(reason_text(), lang()) -> stream_error(). serr_conflict(Text, Lang) -> serr('conflict', Text, Lang). -spec serr_connection_timeout() -> stream_error(). serr_connection_timeout() -> serr('connection-timeout'). -spec serr_connection_timeout(reason_text(), lang()) -> stream_error(). serr_connection_timeout(Text, Lang) -> serr('connection-timeout', Text, Lang). -spec serr_host_gone() -> stream_error(). serr_host_gone() -> serr('host-gone'). -spec serr_host_gone(reason_text(), lang()) -> stream_error(). serr_host_gone(Text, Lang) -> serr('host-gone', Text, Lang). -spec serr_host_unknown() -> stream_error(). serr_host_unknown() -> serr('host-unknown'). -spec serr_host_unknown(reason_text(), lang()) -> stream_error(). serr_host_unknown(Text, Lang) -> serr('host-unknown', Text, Lang). -spec serr_improper_addressing() -> stream_error(). serr_improper_addressing() -> serr('improper-addressing'). -spec serr_improper_addressing(reason_text(), lang()) -> stream_error(). serr_improper_addressing(Text, Lang) -> serr('improper-addressing', Text, Lang). -spec serr_internal_server_error() -> stream_error(). serr_internal_server_error() -> serr('internal-server-error'). -spec serr_internal_server_error(reason_text(), lang()) -> stream_error(). serr_internal_server_error(Text, Lang) -> serr('internal-server-error', Text, Lang). -spec serr_invalid_from() -> stream_error(). serr_invalid_from() -> serr('invalid-from'). -spec serr_invalid_from(reason_text(), lang()) -> stream_error(). serr_invalid_from(Text, Lang) -> serr('invalid-from', Text, Lang). -spec serr_invalid_id() -> stream_error(). serr_invalid_id() -> serr('invalid-id'). -spec serr_invalid_id(reason_text(), lang()) -> stream_error(). serr_invalid_id(Text, Lang) -> serr('invalid-id', Text, Lang). -spec serr_invalid_namespace() -> stream_error(). serr_invalid_namespace() -> serr('invalid-namespace'). -spec serr_invalid_namespace(reason_text(), lang()) -> stream_error(). serr_invalid_namespace(Text, Lang) -> serr('invalid-namespace', Text, Lang). -spec serr_invalid_xml() -> stream_error(). serr_invalid_xml() -> serr('invalid-xml'). -spec serr_invalid_xml(reason_text(), lang()) -> stream_error(). serr_invalid_xml(Text, Lang) -> serr('invalid-xml', Text, Lang). -spec serr_not_authorized() -> stream_error(). serr_not_authorized() -> serr('not-authorized'). -spec serr_not_authorized(reason_text(), lang()) -> stream_error(). serr_not_authorized(Text, Lang) -> serr('not-authorized', Text, Lang). -spec serr_not_well_formed() -> stream_error(). serr_not_well_formed() -> serr('not-well-formed'). -spec serr_not_well_formed(reason_text(), lang()) -> stream_error(). serr_not_well_formed(Text, Lang) -> serr('not-well-formed', Text, Lang). -spec serr_policy_violation() -> stream_error(). serr_policy_violation() -> serr('policy-violation'). -spec serr_policy_violation(reason_text(), lang()) -> stream_error(). serr_policy_violation(Text, Lang) -> serr('policy-violation', Text, Lang). -spec serr_remote_connection_failed() -> stream_error(). serr_remote_connection_failed() -> serr('remote-connection-failed'). -spec serr_remote_connection_failed(reason_text(), lang()) -> stream_error(). serr_remote_connection_failed(Text, Lang) -> serr('remote-connection-failed', Text, Lang). -spec serr_reset() -> stream_error(). serr_reset() -> serr('reset'). -spec serr_reset(reason_text(), lang()) -> stream_error(). serr_reset(Text, Lang) -> serr('reset', Text, Lang). -spec serr_resource_constraint() -> stream_error(). serr_resource_constraint() -> serr('resource-constraint'). -spec serr_resource_constraint(reason_text(), lang()) -> stream_error(). serr_resource_constraint(Text, Lang) -> serr('resource-constraint', Text, Lang). -spec serr_restricted_xml() -> stream_error(). serr_restricted_xml() -> serr('restricted-xml'). -spec serr_restricted_xml(reason_text(), lang()) -> stream_error(). serr_restricted_xml(Text, Lang) -> serr('restricted-xml', Text, Lang). -spec serr_see_other_host(xmpp_host()) -> stream_error(). serr_see_other_host(HostPort) -> serr(#'see-other-host'{host = HostPort}). -spec serr_see_other_host(xmpp_host(), reason_text(), lang()) -> stream_error(). serr_see_other_host(HostPort, Text, Lang) -> serr(#'see-other-host'{host = HostPort}, Text, Lang). -spec serr_system_shutdown() -> stream_error(). serr_system_shutdown() -> serr('system-shutdown'). -spec serr_system_shutdown(reason_text(), lang()) -> stream_error(). serr_system_shutdown(Text, Lang) -> serr('system-shutdown', Text, Lang). -spec serr_undefined_condition() -> stream_error(). serr_undefined_condition() -> serr('undefined-condition'). -spec serr_undefined_condition(reason_text(), lang()) -> stream_error(). serr_undefined_condition(Text, Lang) -> serr('undefined-condition', Text, Lang). -spec serr_unsupported_encoding() -> stream_error(). serr_unsupported_encoding() -> serr('unsupported-encoding'). -spec serr_unsupported_encoding(reason_text(), lang()) -> stream_error(). serr_unsupported_encoding(Text, Lang) -> serr('unsupported-encoding', Text, Lang). -spec serr_unsupported_feature() -> stream_error(). serr_unsupported_feature() -> serr('unsupported-feature'). -spec serr_unsupported_feature(reason_text(), lang()) -> stream_error(). serr_unsupported_feature(Text, Lang) -> serr('unsupported-feature', Text, Lang). -spec serr_unsupported_stanza_type() -> stream_error(). serr_unsupported_stanza_type() -> serr('unsupported-stanza-type'). -spec serr_unsupported_stanza_type(reason_text(), lang()) -> stream_error(). serr_unsupported_stanza_type(Text, Lang) -> serr('unsupported-stanza-type', Text, Lang). -spec serr_unsupported_version() -> stream_error(). serr_unsupported_version() -> serr('unsupported-version'). -spec serr_unsupported_version(reason_text(), lang()) -> stream_error(). serr_unsupported_version(Text, Lang) -> serr('unsupported-version', Text, Lang). %%%=================================================================== %%% Internal functions %%%=================================================================== -spec err('auth' | 'cancel' | 'continue' | 'modify' | 'wait', atom() | gone() | redirect(), non_neg_integer()) -> stanza_error(). err(Type, Reason, Code) -> #stanza_error{type = Type, reason = Reason, code = Code}. -spec err('auth' | 'cancel' | 'continue' | 'modify' | 'wait', atom() | gone() | redirect(), non_neg_integer(), reason_text(), lang()) -> stanza_error(). err(Type, Reason, Code, Text, Lang) -> #stanza_error{type = Type, reason = Reason, code = Code, text = mk_text(Text, Lang)}. -spec serr(atom() | 'see-other-host'()) -> stream_error(). serr(Reason) -> #stream_error{reason = Reason}. -spec serr(atom() | 'see-other-host'(), reason_text(), binary()) -> stream_error(). serr(Reason, Text, Lang) -> #stream_error{reason = Reason, text = mk_text(Text, Lang)}. -spec match_tag(xmlel() | xmpp_element(), binary(), binary(), binary()) -> boolean(). match_tag(El, TagName, XMLNS, TopXMLNS) -> case get_name(El) of TagName -> case get_ns(El) of XMLNS -> true; <<"">> -> XMLNS == TopXMLNS; _ -> false end; _ -> false end. -spec prep_lang(binary()) -> binary(). prep_lang(L) -> [H|_] = binary:split(L, <<"-">>), << <<(if X >= $A, X =< $Z -> X + 32; true -> X end)>> || <> <= H >>. -spec get_text([text()], binary(), binary()) -> binary(). get_text([#text{lang = L, data = Data}|Text], Lang, Result) -> case prep_lang(L) of Lang -> Data; L1 when L1 == <<"">>; L1 == <<"en">>; Result == <<"">> -> get_text(Text, Lang, Data); _ -> get_text(Text, Lang, Result) end; get_text([], _Lang, Result) -> Result. -spec get_tr_forms({module(), atom()} | undefined) -> [erl_parse:abstract_form()]. get_tr_forms(Callback) -> Module = "-module(xmpp_tr).", Export = "-export([tr/2]).", Tr = case Callback of {Mod, Fun} -> io_lib:format("tr(Lang, Text) -> '~s':'~s'(Lang, Text).", [Mod, Fun]); undefined -> "tr(_, Text) -> Text." end, lists:map( fun(Expr) -> {ok, Tokens, _} = erl_scan:string(lists:flatten(Expr)), {ok, Form} = erl_parse:parse_form(Tokens), Form end, [Module, Export, Tr]). -spec format_s_error(atom() | gone() | redirect() | 'see-other-host'(), [text()], binary()) -> binary(). format_s_error(Reason, Text, Lang) -> Slogan = if Reason == undefined -> <<"no reason">>; is_atom(Reason) -> atom_to_binary(Reason, latin1); is_tuple(Reason) -> atom_to_binary(element(1, Reason), latin1) end, case xmpp:get_text(Text, Lang) of <<"">> -> Slogan; Data -> <> end. pp(jid, 6) -> record_info(fields, jid); pp(Name, Arity) -> xmpp_codec:pp(Name, Arity). xmpp-1.4.4/src/captcha_form.erl0000644000232200023220000006270313610066730017005 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: captcha_form.xdata %% Form type: urn:xmpp:captcha %% Document: XEP-0158 -module(captcha_form). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("captcha_form.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [answers | audio_recog | challenge | from | ocr | picture_q | picture_recog | qa | 'SHA-256' | sid | speech_q | speech_recog | video_q | video_recog | 'captcha-fallback-text' | 'captcha-fallback-url']) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"urn:xmpp:captcha">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {answers, Val} -> [encode_answers(Val, Lang, lists:member(answers, Required))]; {audio_recog, Val} -> [encode_audio_recog(Val, Lang, lists:member(audio_recog, Required))]; {challenge, Val} -> [encode_challenge(Val, Lang, lists:member(challenge, Required))]; {from, Val} -> [encode_from(Val, Lang, lists:member(from, Required))]; {ocr, Val} -> [encode_ocr(Val, Lang, lists:member(ocr, Required))]; {picture_q, Val} -> [encode_picture_q(Val, Lang, lists:member(picture_q, Required))]; {picture_recog, Val} -> [encode_picture_recog(Val, Lang, lists:member(picture_recog, Required))]; {qa, Val} -> [encode_qa(Val, Lang, lists:member(qa, Required))]; {'SHA-256', Val} -> ['encode_SHA-256'(Val, Lang, lists:member('SHA-256', Required))]; {sid, Val} -> [encode_sid(Val, Lang, lists:member(sid, Required))]; {speech_q, Val} -> [encode_speech_q(Val, Lang, lists:member(speech_q, Required))]; {speech_recog, Val} -> [encode_speech_recog(Val, Lang, lists:member(speech_recog, Required))]; {video_q, Val} -> [encode_video_q(Val, Lang, lists:member(video_q, Required))]; {video_recog, Val} -> [encode_video_recog(Val, Lang, lists:member(video_recog, Required))]; {'captcha-fallback-text', Val} -> ['encode_captcha-fallback-text'(Val, Lang, lists:member('captcha-fallback-text', Required))]; {'captcha-fallback-url', Val} -> ['encode_captcha-fallback-url'(Val, Lang, lists:member('captcha-fallback-url', Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"urn:xmpp:captcha">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"answers">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"answers">>, Required), [{answers, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"answers">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"answers">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"answers">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"answers">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"answers">>, XMLNS}}); do_decode([#xdata_field{var = <<"audio_recog">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"audio_recog">>, Required), [{audio_recog, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"audio_recog">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"audio_recog">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"audio_recog">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"audio_recog">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"audio_recog">>, XMLNS}}); do_decode([#xdata_field{var = <<"challenge">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"challenge">>, Required), [{challenge, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"challenge">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"challenge">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"challenge">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"challenge">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"challenge">>, XMLNS}}); do_decode([#xdata_field{var = <<"from">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try jid:decode(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"from">>, Required), [{from, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"from">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"from">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"from">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"from">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"from">>, XMLNS}}); do_decode([#xdata_field{var = <<"ocr">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"ocr">>, Required), [{ocr, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"ocr">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"ocr">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"ocr">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"ocr">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"ocr">>, XMLNS}}); do_decode([#xdata_field{var = <<"picture_q">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"picture_q">>, Required), [{picture_q, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"picture_q">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"picture_q">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"picture_q">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"picture_q">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"picture_q">>, XMLNS}}); do_decode([#xdata_field{var = <<"picture_recog">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"picture_recog">>, Required), [{picture_recog, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"picture_recog">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"picture_recog">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"picture_recog">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"picture_recog">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"picture_recog">>, XMLNS}}); do_decode([#xdata_field{var = <<"qa">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"qa">>, Required), [{qa, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"qa">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"qa">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"qa">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"qa">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"qa">>, XMLNS}}); do_decode([#xdata_field{var = <<"SHA-256">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"SHA-256">>, Required), [{'SHA-256', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"SHA-256">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"SHA-256">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"SHA-256">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"SHA-256">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"SHA-256">>, XMLNS}}); do_decode([#xdata_field{var = <<"sid">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"sid">>, Required), [{sid, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"sid">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"sid">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"sid">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"sid">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"sid">>, XMLNS}}); do_decode([#xdata_field{var = <<"speech_q">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"speech_q">>, Required), [{speech_q, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"speech_q">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"speech_q">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"speech_q">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"speech_q">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"speech_q">>, XMLNS}}); do_decode([#xdata_field{var = <<"speech_recog">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"speech_recog">>, Required), [{speech_recog, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"speech_recog">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"speech_recog">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"speech_recog">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"speech_recog">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"speech_recog">>, XMLNS}}); do_decode([#xdata_field{var = <<"video_q">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"video_q">>, Required), [{video_q, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"video_q">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"video_q">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"video_q">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"video_q">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"video_q">>, XMLNS}}); do_decode([#xdata_field{var = <<"video_recog">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"video_recog">>, Required), [{video_recog, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"video_recog">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"video_recog">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"video_recog">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"video_recog">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"video_recog">>, XMLNS}}); do_decode([#xdata_field{var = <<"captcha-fallback-text">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"captcha-fallback-text">>, Required), [{'captcha-fallback-text', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"captcha-fallback-text">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"captcha-fallback-text">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"captcha-fallback-text">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"captcha-fallback-text">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"captcha-fallback-text">>, XMLNS}}); do_decode([#xdata_field{var = <<"captcha-fallback-url">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"captcha-fallback-url">>, Required), [{'captcha-fallback-url', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"captcha-fallback-url">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"captcha-fallback-url">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"captcha-fallback-url">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"captcha-fallback-url">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"captcha-fallback-url">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_answers(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_answers(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"answers">>, values = Values, required = IsRequired, type = hidden, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Number of answers required"))}. -spec encode_audio_recog(binary(), binary(), boolean()) -> xdata_field(). encode_audio_recog(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"audio_recog">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Text associated with a sound"))}. -spec encode_challenge(binary(), binary(), boolean()) -> xdata_field(). encode_challenge(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"challenge">>, values = Values, required = IsRequired, type = hidden, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Challenge ID"))}. -spec encode_from(jid:jid() | undefined, binary(), boolean()) -> xdata_field(). encode_from(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [jid:encode(Value)] end, Opts = [], #xdata_field{var = <<"from">>, values = Values, required = IsRequired, type = hidden, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Attribute 'to' of stanza that triggered " "challenge"))}. -spec encode_ocr(binary(), binary(), boolean()) -> xdata_field(). encode_ocr(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"ocr">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Enter the text you see"))}. -spec encode_picture_q(binary(), binary(), boolean()) -> xdata_field(). encode_picture_q(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"picture_q">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Answer associated with a picture"))}. -spec encode_picture_recog(binary(), binary(), boolean()) -> xdata_field(). encode_picture_recog(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"picture_recog">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Text associated with a picture"))}. -spec encode_qa(binary(), binary(), boolean()) -> xdata_field(). encode_qa(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"qa">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Answer to a question"))}. -spec 'encode_SHA-256'(binary(), binary(), boolean()) -> xdata_field(). 'encode_SHA-256'(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"SHA-256">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Least significant bits of SHA-256 hash " "of text should equal hexadecimal label"))}. -spec encode_sid(binary(), binary(), boolean()) -> xdata_field(). encode_sid(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"sid">>, values = Values, required = IsRequired, type = hidden, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Stanza ID"))}. -spec encode_speech_q(binary(), binary(), boolean()) -> xdata_field(). encode_speech_q(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"speech_q">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Answer associated with speech"))}. -spec encode_speech_recog(binary(), binary(), boolean()) -> xdata_field(). encode_speech_recog(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"speech_recog">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Text associated with speech"))}. -spec encode_video_q(binary(), binary(), boolean()) -> xdata_field(). encode_video_q(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"video_q">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Answer associated with a video"))}. -spec encode_video_recog(binary(), binary(), boolean()) -> xdata_field(). encode_video_recog(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"video_recog">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Text associated with a video"))}. -spec 'encode_captcha-fallback-text'(binary(), binary(), boolean()) -> xdata_field(). 'encode_captcha-fallback-text'(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"captcha-fallback-text">>, values = Values, required = IsRequired, type = fixed, options = Opts, desc = <<>>, label = <<>>}. -spec 'encode_captcha-fallback-url'(binary(), binary(), boolean()) -> xdata_field(). 'encode_captcha-fallback-url'(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"captcha-fallback-url">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("CAPTCHA web page"))}. xmpp-1.4.4/src/xep0050.erl0000644000232200023220000004535313610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0050). -compile(export_all). do_decode(<<"command">>, <<"http://jabber.org/protocol/commands">>, El, Opts) -> decode_adhoc_command(<<"http://jabber.org/protocol/commands">>, Opts, El); do_decode(<<"note">>, <<"http://jabber.org/protocol/commands">>, El, Opts) -> decode_adhoc_command_notes(<<"http://jabber.org/protocol/commands">>, Opts, El); do_decode(<<"actions">>, <<"http://jabber.org/protocol/commands">>, El, Opts) -> decode_adhoc_command_actions(<<"http://jabber.org/protocol/commands">>, Opts, El); do_decode(<<"complete">>, <<"http://jabber.org/protocol/commands">>, El, Opts) -> decode_adhoc_command_complete(<<"http://jabber.org/protocol/commands">>, Opts, El); do_decode(<<"next">>, <<"http://jabber.org/protocol/commands">>, El, Opts) -> decode_adhoc_command_next(<<"http://jabber.org/protocol/commands">>, Opts, El); do_decode(<<"prev">>, <<"http://jabber.org/protocol/commands">>, El, Opts) -> decode_adhoc_command_prev(<<"http://jabber.org/protocol/commands">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"command">>, <<"http://jabber.org/protocol/commands">>}, {<<"note">>, <<"http://jabber.org/protocol/commands">>}, {<<"actions">>, <<"http://jabber.org/protocol/commands">>}, {<<"complete">>, <<"http://jabber.org/protocol/commands">>}, {<<"next">>, <<"http://jabber.org/protocol/commands">>}, {<<"prev">>, <<"http://jabber.org/protocol/commands">>}]. do_encode({adhoc_actions, _, _, _, _} = Actions, TopXMLNS) -> encode_adhoc_command_actions(Actions, TopXMLNS); do_encode({adhoc_note, _, _} = Note, TopXMLNS) -> encode_adhoc_command_notes(Note, TopXMLNS); do_encode({adhoc_command, _, _, _, _, _, _, _, _} = Command, TopXMLNS) -> encode_adhoc_command(Command, TopXMLNS). do_get_name({adhoc_actions, _, _, _, _}) -> <<"actions">>; do_get_name({adhoc_command, _, _, _, _, _, _, _, _}) -> <<"command">>; do_get_name({adhoc_note, _, _}) -> <<"note">>. do_get_ns({adhoc_actions, _, _, _, _}) -> <<"http://jabber.org/protocol/commands">>; do_get_ns({adhoc_command, _, _, _, _, _, _, _, _}) -> <<"http://jabber.org/protocol/commands">>; do_get_ns({adhoc_note, _, _}) -> <<"http://jabber.org/protocol/commands">>. pp(adhoc_actions, 4) -> [execute, prev, next, complete]; pp(adhoc_note, 2) -> [type, data]; pp(adhoc_command, 8) -> [node, action, sid, status, lang, actions, notes, xdata]; pp(_, _) -> no. records() -> [{adhoc_actions, 4}, {adhoc_note, 2}, {adhoc_command, 8}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). decode_adhoc_command(__TopXMLNS, __Opts, {xmlel, <<"command">>, _attrs, _els}) -> {Xdata, Notes, Actions} = decode_adhoc_command_els(__TopXMLNS, __Opts, _els, undefined, [], undefined), {Node, Lang, Sid, Status, Action} = decode_adhoc_command_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {adhoc_command, Node, Action, Sid, Status, Lang, Actions, Notes, Xdata}. decode_adhoc_command_els(__TopXMLNS, __Opts, [], Xdata, Notes, Actions) -> {Xdata, lists:reverse(Notes), Actions}; decode_adhoc_command_els(__TopXMLNS, __Opts, [{xmlel, <<"actions">>, _attrs, _} = _el | _els], Xdata, Notes, Actions) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/commands">> -> decode_adhoc_command_els(__TopXMLNS, __Opts, _els, Xdata, Notes, decode_adhoc_command_actions(<<"http://jabber.org/protocol/commands">>, __Opts, _el)); _ -> decode_adhoc_command_els(__TopXMLNS, __Opts, _els, Xdata, Notes, Actions) end; decode_adhoc_command_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata, Notes, Actions) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_adhoc_command_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el), Notes, Actions); _ -> decode_adhoc_command_els(__TopXMLNS, __Opts, _els, Xdata, Notes, Actions) end; decode_adhoc_command_els(__TopXMLNS, __Opts, [{xmlel, <<"note">>, _attrs, _} = _el | _els], Xdata, Notes, Actions) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/commands">> -> decode_adhoc_command_els(__TopXMLNS, __Opts, _els, Xdata, [decode_adhoc_command_notes(<<"http://jabber.org/protocol/commands">>, __Opts, _el) | Notes], Actions); _ -> decode_adhoc_command_els(__TopXMLNS, __Opts, _els, Xdata, Notes, Actions) end; decode_adhoc_command_els(__TopXMLNS, __Opts, [_ | _els], Xdata, Notes, Actions) -> decode_adhoc_command_els(__TopXMLNS, __Opts, _els, Xdata, Notes, Actions). decode_adhoc_command_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node, Lang, Sid, Status, Action) -> decode_adhoc_command_attrs(__TopXMLNS, _attrs, _val, Lang, Sid, Status, Action); decode_adhoc_command_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], Node, _Lang, Sid, Status, Action) -> decode_adhoc_command_attrs(__TopXMLNS, _attrs, Node, _val, Sid, Status, Action); decode_adhoc_command_attrs(__TopXMLNS, [{<<"sessionid">>, _val} | _attrs], Node, Lang, _Sid, Status, Action) -> decode_adhoc_command_attrs(__TopXMLNS, _attrs, Node, Lang, _val, Status, Action); decode_adhoc_command_attrs(__TopXMLNS, [{<<"status">>, _val} | _attrs], Node, Lang, Sid, _Status, Action) -> decode_adhoc_command_attrs(__TopXMLNS, _attrs, Node, Lang, Sid, _val, Action); decode_adhoc_command_attrs(__TopXMLNS, [{<<"action">>, _val} | _attrs], Node, Lang, Sid, Status, _Action) -> decode_adhoc_command_attrs(__TopXMLNS, _attrs, Node, Lang, Sid, Status, _val); decode_adhoc_command_attrs(__TopXMLNS, [_ | _attrs], Node, Lang, Sid, Status, Action) -> decode_adhoc_command_attrs(__TopXMLNS, _attrs, Node, Lang, Sid, Status, Action); decode_adhoc_command_attrs(__TopXMLNS, [], Node, Lang, Sid, Status, Action) -> {decode_adhoc_command_attr_node(__TopXMLNS, Node), 'decode_adhoc_command_attr_xml:lang'(__TopXMLNS, Lang), decode_adhoc_command_attr_sessionid(__TopXMLNS, Sid), decode_adhoc_command_attr_status(__TopXMLNS, Status), decode_adhoc_command_attr_action(__TopXMLNS, Action)}. encode_adhoc_command({adhoc_command, Node, Action, Sid, Status, Lang, Actions, Notes, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/commands">>, [], __TopXMLNS), _els = lists:reverse('encode_adhoc_command_$xdata'(Xdata, __NewTopXMLNS, 'encode_adhoc_command_$notes'(Notes, __NewTopXMLNS, 'encode_adhoc_command_$actions'(Actions, __NewTopXMLNS, [])))), _attrs = encode_adhoc_command_attr_action(Action, encode_adhoc_command_attr_status(Status, encode_adhoc_command_attr_sessionid(Sid, 'encode_adhoc_command_attr_xml:lang'(Lang, encode_adhoc_command_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"command">>, _attrs, _els}. 'encode_adhoc_command_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_adhoc_command_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. 'encode_adhoc_command_$notes'([], __TopXMLNS, _acc) -> _acc; 'encode_adhoc_command_$notes'([Notes | _els], __TopXMLNS, _acc) -> 'encode_adhoc_command_$notes'(_els, __TopXMLNS, [encode_adhoc_command_notes(Notes, __TopXMLNS) | _acc]). 'encode_adhoc_command_$actions'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_adhoc_command_$actions'(Actions, __TopXMLNS, _acc) -> [encode_adhoc_command_actions(Actions, __TopXMLNS) | _acc]. decode_adhoc_command_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"command">>, __TopXMLNS}}); decode_adhoc_command_attr_node(__TopXMLNS, _val) -> _val. encode_adhoc_command_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. 'decode_adhoc_command_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_adhoc_command_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"command">>, __TopXMLNS}}); _res -> _res end. 'encode_adhoc_command_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_adhoc_command_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_adhoc_command_attr_sessionid(__TopXMLNS, undefined) -> <<>>; decode_adhoc_command_attr_sessionid(__TopXMLNS, _val) -> _val. encode_adhoc_command_attr_sessionid(<<>>, _acc) -> _acc; encode_adhoc_command_attr_sessionid(_val, _acc) -> [{<<"sessionid">>, _val} | _acc]. decode_adhoc_command_attr_status(__TopXMLNS, undefined) -> undefined; decode_adhoc_command_attr_status(__TopXMLNS, _val) -> case catch dec_enum(_val, [canceled, completed, executing]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"status">>, <<"command">>, __TopXMLNS}}); _res -> _res end. encode_adhoc_command_attr_status(undefined, _acc) -> _acc; encode_adhoc_command_attr_status(_val, _acc) -> [{<<"status">>, enc_enum(_val)} | _acc]. decode_adhoc_command_attr_action(__TopXMLNS, undefined) -> execute; decode_adhoc_command_attr_action(__TopXMLNS, _val) -> case catch dec_enum(_val, [cancel, complete, execute, next, prev]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"action">>, <<"command">>, __TopXMLNS}}); _res -> _res end. encode_adhoc_command_attr_action(execute, _acc) -> _acc; encode_adhoc_command_attr_action(_val, _acc) -> [{<<"action">>, enc_enum(_val)} | _acc]. decode_adhoc_command_notes(__TopXMLNS, __Opts, {xmlel, <<"note">>, _attrs, _els}) -> Data = decode_adhoc_command_notes_els(__TopXMLNS, __Opts, _els, <<>>), Type = decode_adhoc_command_notes_attrs(__TopXMLNS, _attrs, undefined), {adhoc_note, Type, Data}. decode_adhoc_command_notes_els(__TopXMLNS, __Opts, [], Data) -> decode_adhoc_command_notes_cdata(__TopXMLNS, Data); decode_adhoc_command_notes_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_adhoc_command_notes_els(__TopXMLNS, __Opts, _els, <>); decode_adhoc_command_notes_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_adhoc_command_notes_els(__TopXMLNS, __Opts, _els, Data). decode_adhoc_command_notes_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], _Type) -> decode_adhoc_command_notes_attrs(__TopXMLNS, _attrs, _val); decode_adhoc_command_notes_attrs(__TopXMLNS, [_ | _attrs], Type) -> decode_adhoc_command_notes_attrs(__TopXMLNS, _attrs, Type); decode_adhoc_command_notes_attrs(__TopXMLNS, [], Type) -> decode_adhoc_command_notes_attr_type(__TopXMLNS, Type). encode_adhoc_command_notes({adhoc_note, Type, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/commands">>, [], __TopXMLNS), _els = encode_adhoc_command_notes_cdata(Data, []), _attrs = encode_adhoc_command_notes_attr_type(Type, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"note">>, _attrs, _els}. decode_adhoc_command_notes_attr_type(__TopXMLNS, undefined) -> info; decode_adhoc_command_notes_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [info, warn, error]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"note">>, __TopXMLNS}}); _res -> _res end. encode_adhoc_command_notes_attr_type(info, _acc) -> _acc; encode_adhoc_command_notes_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_adhoc_command_notes_cdata(__TopXMLNS, <<>>) -> <<>>; decode_adhoc_command_notes_cdata(__TopXMLNS, _val) -> _val. encode_adhoc_command_notes_cdata(<<>>, _acc) -> _acc; encode_adhoc_command_notes_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_adhoc_command_actions(__TopXMLNS, __Opts, {xmlel, <<"actions">>, _attrs, _els}) -> {Next, Complete, Prev} = decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, false, false, false), Execute = decode_adhoc_command_actions_attrs(__TopXMLNS, _attrs, undefined), {adhoc_actions, Execute, Prev, Next, Complete}. decode_adhoc_command_actions_els(__TopXMLNS, __Opts, [], Next, Complete, Prev) -> {Next, Complete, Prev}; decode_adhoc_command_actions_els(__TopXMLNS, __Opts, [{xmlel, <<"prev">>, _attrs, _} = _el | _els], Next, Complete, Prev) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/commands">> -> decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, Next, Complete, decode_adhoc_command_prev(<<"http://jabber.org/protocol/commands">>, __Opts, _el)); _ -> decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, Next, Complete, Prev) end; decode_adhoc_command_actions_els(__TopXMLNS, __Opts, [{xmlel, <<"next">>, _attrs, _} = _el | _els], Next, Complete, Prev) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/commands">> -> decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, decode_adhoc_command_next(<<"http://jabber.org/protocol/commands">>, __Opts, _el), Complete, Prev); _ -> decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, Next, Complete, Prev) end; decode_adhoc_command_actions_els(__TopXMLNS, __Opts, [{xmlel, <<"complete">>, _attrs, _} = _el | _els], Next, Complete, Prev) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/commands">> -> decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, Next, decode_adhoc_command_complete(<<"http://jabber.org/protocol/commands">>, __Opts, _el), Prev); _ -> decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, Next, Complete, Prev) end; decode_adhoc_command_actions_els(__TopXMLNS, __Opts, [_ | _els], Next, Complete, Prev) -> decode_adhoc_command_actions_els(__TopXMLNS, __Opts, _els, Next, Complete, Prev). decode_adhoc_command_actions_attrs(__TopXMLNS, [{<<"execute">>, _val} | _attrs], _Execute) -> decode_adhoc_command_actions_attrs(__TopXMLNS, _attrs, _val); decode_adhoc_command_actions_attrs(__TopXMLNS, [_ | _attrs], Execute) -> decode_adhoc_command_actions_attrs(__TopXMLNS, _attrs, Execute); decode_adhoc_command_actions_attrs(__TopXMLNS, [], Execute) -> decode_adhoc_command_actions_attr_execute(__TopXMLNS, Execute). encode_adhoc_command_actions({adhoc_actions, Execute, Prev, Next, Complete}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/commands">>, [], __TopXMLNS), _els = lists:reverse('encode_adhoc_command_actions_$next'(Next, __NewTopXMLNS, 'encode_adhoc_command_actions_$complete'(Complete, __NewTopXMLNS, 'encode_adhoc_command_actions_$prev'(Prev, __NewTopXMLNS, [])))), _attrs = encode_adhoc_command_actions_attr_execute(Execute, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"actions">>, _attrs, _els}. 'encode_adhoc_command_actions_$next'(false, __TopXMLNS, _acc) -> _acc; 'encode_adhoc_command_actions_$next'(Next, __TopXMLNS, _acc) -> [encode_adhoc_command_next(Next, __TopXMLNS) | _acc]. 'encode_adhoc_command_actions_$complete'(false, __TopXMLNS, _acc) -> _acc; 'encode_adhoc_command_actions_$complete'(Complete, __TopXMLNS, _acc) -> [encode_adhoc_command_complete(Complete, __TopXMLNS) | _acc]. 'encode_adhoc_command_actions_$prev'(false, __TopXMLNS, _acc) -> _acc; 'encode_adhoc_command_actions_$prev'(Prev, __TopXMLNS, _acc) -> [encode_adhoc_command_prev(Prev, __TopXMLNS) | _acc]. decode_adhoc_command_actions_attr_execute(__TopXMLNS, undefined) -> undefined; decode_adhoc_command_actions_attr_execute(__TopXMLNS, _val) -> case catch dec_enum(_val, [complete, next, prev]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"execute">>, <<"actions">>, __TopXMLNS}}); _res -> _res end. encode_adhoc_command_actions_attr_execute(undefined, _acc) -> _acc; encode_adhoc_command_actions_attr_execute(_val, _acc) -> [{<<"execute">>, enc_enum(_val)} | _acc]. decode_adhoc_command_complete(__TopXMLNS, __Opts, {xmlel, <<"complete">>, _attrs, _els}) -> true. encode_adhoc_command_complete(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/commands">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"complete">>, _attrs, _els}. decode_adhoc_command_next(__TopXMLNS, __Opts, {xmlel, <<"next">>, _attrs, _els}) -> true. encode_adhoc_command_next(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/commands">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"next">>, _attrs, _els}. decode_adhoc_command_prev(__TopXMLNS, __Opts, {xmlel, <<"prev">>, _attrs, _els}) -> true. encode_adhoc_command_prev(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/commands">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"prev">>, _attrs, _els}. xmpp-1.4.4/src/xep0066.erl0000644000232200023220000001320013610066730015453 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0066). -compile(export_all). do_decode(<<"x">>, <<"jabber:x:oob">>, El, Opts) -> decode_oob_x(<<"jabber:x:oob">>, Opts, El); do_decode(<<"desc">>, <<"jabber:x:oob">>, El, Opts) -> decode_oob_desc(<<"jabber:x:oob">>, Opts, El); do_decode(<<"url">>, <<"jabber:x:oob">>, El, Opts) -> decode_oob_url(<<"jabber:x:oob">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"x">>, <<"jabber:x:oob">>}, {<<"desc">>, <<"jabber:x:oob">>}, {<<"url">>, <<"jabber:x:oob">>}]. do_encode({oob_x, _, _, _} = X, TopXMLNS) -> encode_oob_x(X, TopXMLNS). do_get_name({oob_x, _, _, _}) -> <<"x">>. do_get_ns({oob_x, _, _, _}) -> <<"jabber:x:oob">>. pp(oob_x, 3) -> [url, desc, sid]; pp(_, _) -> no. records() -> [{oob_x, 3}]. decode_oob_x(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> {Desc, Url} = decode_oob_x_els(__TopXMLNS, __Opts, _els, <<>>, error), Sid = decode_oob_x_attrs(__TopXMLNS, _attrs, undefined), {oob_x, Url, Desc, Sid}. decode_oob_x_els(__TopXMLNS, __Opts, [], Desc, Url) -> {Desc, case Url of error -> erlang:error({xmpp_codec, {missing_tag, <<"url">>, __TopXMLNS}}); {value, Url1} -> Url1 end}; decode_oob_x_els(__TopXMLNS, __Opts, [{xmlel, <<"url">>, _attrs, _} = _el | _els], Desc, Url) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:oob">> -> decode_oob_x_els(__TopXMLNS, __Opts, _els, Desc, {value, decode_oob_url(<<"jabber:x:oob">>, __Opts, _el)}); _ -> decode_oob_x_els(__TopXMLNS, __Opts, _els, Desc, Url) end; decode_oob_x_els(__TopXMLNS, __Opts, [{xmlel, <<"desc">>, _attrs, _} = _el | _els], Desc, Url) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:oob">> -> decode_oob_x_els(__TopXMLNS, __Opts, _els, decode_oob_desc(<<"jabber:x:oob">>, __Opts, _el), Url); _ -> decode_oob_x_els(__TopXMLNS, __Opts, _els, Desc, Url) end; decode_oob_x_els(__TopXMLNS, __Opts, [_ | _els], Desc, Url) -> decode_oob_x_els(__TopXMLNS, __Opts, _els, Desc, Url). decode_oob_x_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], _Sid) -> decode_oob_x_attrs(__TopXMLNS, _attrs, _val); decode_oob_x_attrs(__TopXMLNS, [_ | _attrs], Sid) -> decode_oob_x_attrs(__TopXMLNS, _attrs, Sid); decode_oob_x_attrs(__TopXMLNS, [], Sid) -> decode_oob_x_attr_sid(__TopXMLNS, Sid). encode_oob_x({oob_x, Url, Desc, Sid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:oob">>, [], __TopXMLNS), _els = lists:reverse('encode_oob_x_$desc'(Desc, __NewTopXMLNS, 'encode_oob_x_$url'(Url, __NewTopXMLNS, []))), _attrs = encode_oob_x_attr_sid(Sid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"x">>, _attrs, _els}. 'encode_oob_x_$desc'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_oob_x_$desc'(Desc, __TopXMLNS, _acc) -> [encode_oob_desc(Desc, __TopXMLNS) | _acc]. 'encode_oob_x_$url'(Url, __TopXMLNS, _acc) -> [encode_oob_url(Url, __TopXMLNS) | _acc]. decode_oob_x_attr_sid(__TopXMLNS, undefined) -> <<>>; decode_oob_x_attr_sid(__TopXMLNS, _val) -> _val. encode_oob_x_attr_sid(<<>>, _acc) -> _acc; encode_oob_x_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. decode_oob_desc(__TopXMLNS, __Opts, {xmlel, <<"desc">>, _attrs, _els}) -> Cdata = decode_oob_desc_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_oob_desc_els(__TopXMLNS, __Opts, [], Cdata) -> decode_oob_desc_cdata(__TopXMLNS, Cdata); decode_oob_desc_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_oob_desc_els(__TopXMLNS, __Opts, _els, <>); decode_oob_desc_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_oob_desc_els(__TopXMLNS, __Opts, _els, Cdata). encode_oob_desc(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:oob">>, [], __TopXMLNS), _els = encode_oob_desc_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"desc">>, _attrs, _els}. decode_oob_desc_cdata(__TopXMLNS, <<>>) -> <<>>; decode_oob_desc_cdata(__TopXMLNS, _val) -> _val. encode_oob_desc_cdata(<<>>, _acc) -> _acc; encode_oob_desc_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_oob_url(__TopXMLNS, __Opts, {xmlel, <<"url">>, _attrs, _els}) -> Cdata = decode_oob_url_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_oob_url_els(__TopXMLNS, __Opts, [], Cdata) -> decode_oob_url_cdata(__TopXMLNS, Cdata); decode_oob_url_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_oob_url_els(__TopXMLNS, __Opts, _els, <>); decode_oob_url_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_oob_url_els(__TopXMLNS, __Opts, _els, Cdata). encode_oob_url(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:oob">>, [], __TopXMLNS), _els = encode_oob_url_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"url">>, _attrs, _els}. decode_oob_url_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"url">>, __TopXMLNS}}); decode_oob_url_cdata(__TopXMLNS, _val) -> _val. encode_oob_url_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/pubsub_get_pending.erl0000644000232200023220000001605613610066730020222 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_get_pending.xdata %% Form type: http://jabber.org/protocol/pubsub#subscribe_authorization %% Document: XEP-0060 -module(pubsub_get_pending). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("pubsub_get_pending.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [node]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/pubsub#subscribe_a" "uthorization">>], [<<"pubsub#node">>], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [<<"pubsub#node">>], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, [node]). encode(Cfg, Lang) -> encode(Cfg, Lang, [node]). encode(List, Lang, Required) -> Fs = [case Opt of {node, Val} -> [encode_node(Val, default, Lang, lists:member(node, Required))]; {node, Val, Opts} -> [encode_node(Val, Opts, Lang, lists:member(node, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/pubsub#subscribe_a" "uthorization">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"pubsub#node">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#node">>, Required), [{node, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#node">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#node">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#node">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#node">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#node">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_node(binary(), default | options(binary()), binary(), boolean()) -> xdata_field(). encode_node(Value, Options, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = if Options == default -> []; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = V} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#node">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The NodeID of the relevant node"))}. xmpp-1.4.4/src/xep0191.erl0000644000232200023220000002045313610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0191). -compile(export_all). do_decode(<<"blocklist">>, <<"urn:xmpp:blocking">>, El, Opts) -> decode_block_list(<<"urn:xmpp:blocking">>, Opts, El); do_decode(<<"unblock">>, <<"urn:xmpp:blocking">>, El, Opts) -> decode_unblock(<<"urn:xmpp:blocking">>, Opts, El); do_decode(<<"block">>, <<"urn:xmpp:blocking">>, El, Opts) -> decode_block(<<"urn:xmpp:blocking">>, Opts, El); do_decode(<<"item">>, <<"urn:xmpp:blocking">>, El, Opts) -> decode_block_item(<<"urn:xmpp:blocking">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"blocklist">>, <<"urn:xmpp:blocking">>}, {<<"unblock">>, <<"urn:xmpp:blocking">>}, {<<"block">>, <<"urn:xmpp:blocking">>}, {<<"item">>, <<"urn:xmpp:blocking">>}]. do_encode({block_item, _, _} = Item, TopXMLNS) -> encode_block_item(Item, TopXMLNS); do_encode({block, _} = Block, TopXMLNS) -> encode_block(Block, TopXMLNS); do_encode({unblock, _} = Unblock, TopXMLNS) -> encode_unblock(Unblock, TopXMLNS); do_encode({block_list, _} = Blocklist, TopXMLNS) -> encode_block_list(Blocklist, TopXMLNS). do_get_name({block, _}) -> <<"block">>; do_get_name({block_item, _, _}) -> <<"item">>; do_get_name({block_list, _}) -> <<"blocklist">>; do_get_name({unblock, _}) -> <<"unblock">>. do_get_ns({block, _}) -> <<"urn:xmpp:blocking">>; do_get_ns({block_item, _, _}) -> <<"urn:xmpp:blocking">>; do_get_ns({block_list, _}) -> <<"urn:xmpp:blocking">>; do_get_ns({unblock, _}) -> <<"urn:xmpp:blocking">>. pp(block_item, 2) -> [jid, spam_report]; pp(block, 1) -> [items]; pp(unblock, 1) -> [items]; pp(block_list, 1) -> [items]; pp(_, _) -> no. records() -> [{block_item, 2}, {block, 1}, {unblock, 1}, {block_list, 1}]. decode_block_list(__TopXMLNS, __Opts, {xmlel, <<"blocklist">>, _attrs, _els}) -> Items = decode_block_list_els(__TopXMLNS, __Opts, _els, []), {block_list, Items}. decode_block_list_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_block_list_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:blocking">> -> decode_block_list_els(__TopXMLNS, __Opts, _els, [decode_block_item(<<"urn:xmpp:blocking">>, __Opts, _el) | Items]); _ -> decode_block_list_els(__TopXMLNS, __Opts, _els, Items) end; decode_block_list_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_block_list_els(__TopXMLNS, __Opts, _els, Items). encode_block_list({block_list, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:blocking">>, [], __TopXMLNS), _els = lists:reverse('encode_block_list_$items'(Items, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"blocklist">>, _attrs, _els}. 'encode_block_list_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_block_list_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_block_list_$items'(_els, __TopXMLNS, [encode_block_item(Items, __TopXMLNS) | _acc]). decode_unblock(__TopXMLNS, __Opts, {xmlel, <<"unblock">>, _attrs, _els}) -> Items = decode_unblock_els(__TopXMLNS, __Opts, _els, []), {unblock, Items}. decode_unblock_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_unblock_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:blocking">> -> decode_unblock_els(__TopXMLNS, __Opts, _els, [decode_block_item(<<"urn:xmpp:blocking">>, __Opts, _el) | Items]); _ -> decode_unblock_els(__TopXMLNS, __Opts, _els, Items) end; decode_unblock_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_unblock_els(__TopXMLNS, __Opts, _els, Items). encode_unblock({unblock, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:blocking">>, [], __TopXMLNS), _els = lists:reverse('encode_unblock_$items'(Items, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unblock">>, _attrs, _els}. 'encode_unblock_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_unblock_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_unblock_$items'(_els, __TopXMLNS, [encode_block_item(Items, __TopXMLNS) | _acc]). decode_block(__TopXMLNS, __Opts, {xmlel, <<"block">>, _attrs, _els}) -> Items = decode_block_els(__TopXMLNS, __Opts, _els, []), {block, Items}. decode_block_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_block_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:blocking">> -> decode_block_els(__TopXMLNS, __Opts, _els, [decode_block_item(<<"urn:xmpp:blocking">>, __Opts, _el) | Items]); _ -> decode_block_els(__TopXMLNS, __Opts, _els, Items) end; decode_block_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_block_els(__TopXMLNS, __Opts, _els, Items). encode_block({block, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:blocking">>, [], __TopXMLNS), _els = lists:reverse('encode_block_$items'(Items, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"block">>, _attrs, _els}. 'encode_block_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_block_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_block_$items'(_els, __TopXMLNS, [encode_block_item(Items, __TopXMLNS) | _acc]). decode_block_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> Spam_report = decode_block_item_els(__TopXMLNS, __Opts, _els, undefined), Jid = decode_block_item_attrs(__TopXMLNS, _attrs, undefined), {block_item, Jid, Spam_report}. decode_block_item_els(__TopXMLNS, __Opts, [], Spam_report) -> Spam_report; decode_block_item_els(__TopXMLNS, __Opts, [{xmlel, <<"report">>, _attrs, _} = _el | _els], Spam_report) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:reporting:0">> -> decode_block_item_els(__TopXMLNS, __Opts, _els, xep0377:decode_report(<<"urn:xmpp:reporting:0">>, __Opts, _el)); _ -> decode_block_item_els(__TopXMLNS, __Opts, _els, Spam_report) end; decode_block_item_els(__TopXMLNS, __Opts, [_ | _els], Spam_report) -> decode_block_item_els(__TopXMLNS, __Opts, _els, Spam_report). decode_block_item_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid) -> decode_block_item_attrs(__TopXMLNS, _attrs, _val); decode_block_item_attrs(__TopXMLNS, [_ | _attrs], Jid) -> decode_block_item_attrs(__TopXMLNS, _attrs, Jid); decode_block_item_attrs(__TopXMLNS, [], Jid) -> decode_block_item_attr_jid(__TopXMLNS, Jid). encode_block_item({block_item, Jid, Spam_report}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:blocking">>, [], __TopXMLNS), _els = lists:reverse('encode_block_item_$spam_report'(Spam_report, __NewTopXMLNS, [])), _attrs = encode_block_item_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"item">>, _attrs, _els}. 'encode_block_item_$spam_report'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_block_item_$spam_report'(Spam_report, __TopXMLNS, _acc) -> [xep0377:encode_report(Spam_report, __TopXMLNS) | _acc]. decode_block_item_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"item">>, __TopXMLNS}}); decode_block_item_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_block_item_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. xmpp-1.4.4/src/push_summary.erl0000644000232200023220000002656513610066730017121 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: push_summary.xdata %% Form type: urn:xmpp:push:summary %% Document: XEP-0357 -module(push_summary). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("push_summary.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), ['message-count' | 'pending-subscription-count' | 'last-message-sender' | 'last-message-body']) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"urn:xmpp:push:summary">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {'message-count', Val} -> ['encode_message-count'(Val, Lang, lists:member('message-count', Required))]; {'pending-subscription-count', Val} -> ['encode_pending-subscription-count'(Val, Lang, lists:member('pending-subscription-count', Required))]; {'last-message-sender', Val} -> ['encode_last-message-sender'(Val, Lang, lists:member('last-message-sender', Required))]; {'last-message-body', Val} -> ['encode_last-message-body'(Val, Lang, lists:member('last-message-body', Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"urn:xmpp:push:summary">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"message-count">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"message-count">>, Required), [{'message-count', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"message-count">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"message-count">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"message-count">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"message-count">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"message-count">>, XMLNS}}); do_decode([#xdata_field{var = <<"pending-subscription-count">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pending-subscription-count">>, Required), [{'pending-subscription-count', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pending-subscription-count">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pending-subscription-count">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pending-subscription-count">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pending-subscription-count">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pending-subscription-count">>, XMLNS}}); do_decode([#xdata_field{var = <<"last-message-sender">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try jid:decode(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"last-message-sender">>, Required), [{'last-message-sender', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"last-message-sender">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"last-message-sender">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"last-message-sender">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"last-message-sender">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"last-message-sender">>, XMLNS}}); do_decode([#xdata_field{var = <<"last-message-body">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"last-message-body">>, Required), [{'last-message-body', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"last-message-body">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"last-message-body">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"last-message-body">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"last-message-body">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"last-message-body">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec 'encode_message-count'(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). 'encode_message-count'(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"message-count">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The number of unread or undelivered " "messages"))}. -spec 'encode_pending-subscription-count'(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). 'encode_pending-subscription-count'(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"pending-subscription-count">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The number of pending incoming presence " "subscription requests"))}. -spec 'encode_last-message-sender'(jid:jid() | undefined, binary(), boolean()) -> xdata_field(). 'encode_last-message-sender'(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [jid:encode(Value)] end, Opts = [], #xdata_field{var = <<"last-message-sender">>, values = Values, required = IsRequired, type = 'jid-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The sender of the last received message"))}. -spec 'encode_last-message-body'(binary(), binary(), boolean()) -> xdata_field(). 'encode_last-message-body'(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"last-message-body">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The body text of the last received message"))}. xmpp-1.4.4/src/xep0012.erl0000644000232200023220000000550413610066730015452 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0012). -compile(export_all). do_decode(<<"query">>, <<"jabber:iq:last">>, El, Opts) -> decode_last(<<"jabber:iq:last">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"jabber:iq:last">>}]. do_encode({last, _, _} = Query, TopXMLNS) -> encode_last(Query, TopXMLNS). do_get_name({last, _, _}) -> <<"query">>. do_get_ns({last, _, _}) -> <<"jabber:iq:last">>. pp(last, 2) -> [seconds, status]; pp(_, _) -> no. records() -> [{last, 2}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_last(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> Status = decode_last_els(__TopXMLNS, __Opts, _els, <<>>), Seconds = decode_last_attrs(__TopXMLNS, _attrs, undefined), {last, Seconds, Status}. decode_last_els(__TopXMLNS, __Opts, [], Status) -> decode_last_cdata(__TopXMLNS, Status); decode_last_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Status) -> decode_last_els(__TopXMLNS, __Opts, _els, <>); decode_last_els(__TopXMLNS, __Opts, [_ | _els], Status) -> decode_last_els(__TopXMLNS, __Opts, _els, Status). decode_last_attrs(__TopXMLNS, [{<<"seconds">>, _val} | _attrs], _Seconds) -> decode_last_attrs(__TopXMLNS, _attrs, _val); decode_last_attrs(__TopXMLNS, [_ | _attrs], Seconds) -> decode_last_attrs(__TopXMLNS, _attrs, Seconds); decode_last_attrs(__TopXMLNS, [], Seconds) -> decode_last_attr_seconds(__TopXMLNS, Seconds). encode_last({last, Seconds, Status}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:last">>, [], __TopXMLNS), _els = encode_last_cdata(Status, []), _attrs = encode_last_attr_seconds(Seconds, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"query">>, _attrs, _els}. decode_last_attr_seconds(__TopXMLNS, undefined) -> undefined; decode_last_attr_seconds(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"seconds">>, <<"query">>, __TopXMLNS}}); _res -> _res end. encode_last_attr_seconds(undefined, _acc) -> _acc; encode_last_attr_seconds(_val, _acc) -> [{<<"seconds">>, enc_int(_val)} | _acc]. decode_last_cdata(__TopXMLNS, <<>>) -> <<>>; decode_last_cdata(__TopXMLNS, _val) -> _val. encode_last_cdata(<<>>, _acc) -> _acc; encode_last_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0077.erl0000644000232200023220000016311313610066730015466 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0077). -compile(export_all). do_decode(<<"query">>, <<"jabber:iq:register">>, El, Opts) -> decode_register(<<"jabber:iq:register">>, Opts, El); do_decode(<<"key">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_key(<<"jabber:iq:register">>, Opts, El); do_decode(<<"text">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_text(<<"jabber:iq:register">>, Opts, El); do_decode(<<"misc">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_misc(<<"jabber:iq:register">>, Opts, El); do_decode(<<"date">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_date(<<"jabber:iq:register">>, Opts, El); do_decode(<<"url">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_url(<<"jabber:iq:register">>, Opts, El); do_decode(<<"phone">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_phone(<<"jabber:iq:register">>, Opts, El); do_decode(<<"zip">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_zip(<<"jabber:iq:register">>, Opts, El); do_decode(<<"state">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_state(<<"jabber:iq:register">>, Opts, El); do_decode(<<"city">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_city(<<"jabber:iq:register">>, Opts, El); do_decode(<<"address">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_address(<<"jabber:iq:register">>, Opts, El); do_decode(<<"email">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_email(<<"jabber:iq:register">>, Opts, El); do_decode(<<"last">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_last(<<"jabber:iq:register">>, Opts, El); do_decode(<<"first">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_first(<<"jabber:iq:register">>, Opts, El); do_decode(<<"name">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_name(<<"jabber:iq:register">>, Opts, El); do_decode(<<"password">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_password(<<"jabber:iq:register">>, Opts, El); do_decode(<<"nick">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_nick(<<"jabber:iq:register">>, Opts, El); do_decode(<<"username">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_username(<<"jabber:iq:register">>, Opts, El); do_decode(<<"instructions">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_instructions(<<"jabber:iq:register">>, Opts, El); do_decode(<<"remove">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_remove(<<"jabber:iq:register">>, Opts, El); do_decode(<<"registered">>, <<"jabber:iq:register">>, El, Opts) -> decode_register_registered(<<"jabber:iq:register">>, Opts, El); do_decode(<<"register">>, <<"http://jabber.org/features/iq-register">>, El, Opts) -> decode_feature_register(<<"http://jabber.org/features/iq-register">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"jabber:iq:register">>}, {<<"key">>, <<"jabber:iq:register">>}, {<<"text">>, <<"jabber:iq:register">>}, {<<"misc">>, <<"jabber:iq:register">>}, {<<"date">>, <<"jabber:iq:register">>}, {<<"url">>, <<"jabber:iq:register">>}, {<<"phone">>, <<"jabber:iq:register">>}, {<<"zip">>, <<"jabber:iq:register">>}, {<<"state">>, <<"jabber:iq:register">>}, {<<"city">>, <<"jabber:iq:register">>}, {<<"address">>, <<"jabber:iq:register">>}, {<<"email">>, <<"jabber:iq:register">>}, {<<"last">>, <<"jabber:iq:register">>}, {<<"first">>, <<"jabber:iq:register">>}, {<<"name">>, <<"jabber:iq:register">>}, {<<"password">>, <<"jabber:iq:register">>}, {<<"nick">>, <<"jabber:iq:register">>}, {<<"username">>, <<"jabber:iq:register">>}, {<<"instructions">>, <<"jabber:iq:register">>}, {<<"remove">>, <<"jabber:iq:register">>}, {<<"registered">>, <<"jabber:iq:register">>}, {<<"register">>, <<"http://jabber.org/features/iq-register">>}]. do_encode({feature_register} = Register, TopXMLNS) -> encode_feature_register(Register, TopXMLNS); do_encode({register, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _} = Query, TopXMLNS) -> encode_register(Query, TopXMLNS). do_get_name({feature_register}) -> <<"register">>; do_get_name({register, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"query">>. do_get_ns({feature_register}) -> <<"http://jabber.org/features/iq-register">>; do_get_ns({register, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> <<"jabber:iq:register">>. get_els({register, _registered, _remove, _instructions, _username, _nick, _password, _name, _first, _last, _email, _address, _city, _state, _zip, _phone, _url, _date, _misc, _text, _key, _xdata, _sub_els}) -> _sub_els. set_els({register, _registered, _remove, _instructions, _username, _nick, _password, _name, _first, _last, _email, _address, _city, _state, _zip, _phone, _url, _date, _misc, _text, _key, _xdata, _}, _sub_els) -> {register, _registered, _remove, _instructions, _username, _nick, _password, _name, _first, _last, _email, _address, _city, _state, _zip, _phone, _url, _date, _misc, _text, _key, _xdata, _sub_els}. pp(feature_register, 0) -> []; pp(register, 22) -> [registered, remove, instructions, username, nick, password, name, first, last, email, address, city, state, zip, phone, url, date, misc, text, key, xdata, sub_els]; pp(_, _) -> no. records() -> [{feature_register, 0}, {register, 22}]. decode_register(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els} = decode_register_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, false, undefined, undefined, undefined, undefined, undefined, false, undefined, undefined, undefined, undefined, undefined, []), {register, Registered, Remove, Instructions, Username, Nick, Password, Name, First, Last, Email, Address, City, State, Zip, Phone, Url, Date, Misc, Text, Key, Xdata, __Els}. decode_register_els(__TopXMLNS, __Opts, [], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> {Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, lists:reverse(__Els)}; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el), Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"registered">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, decode_register_registered(<<"jabber:iq:register">>, __Opts, _el), Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"remove">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, decode_register_remove(<<"jabber:iq:register">>, __Opts, _el), Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"instructions">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, decode_register_instructions(<<"jabber:iq:register">>, __Opts, _el), Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"username">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, decode_register_username(<<"jabber:iq:register">>, __Opts, _el), Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"nick">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, decode_register_nick(<<"jabber:iq:register">>, __Opts, _el), Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"password">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, decode_register_password(<<"jabber:iq:register">>, __Opts, _el), Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"name">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, decode_register_name(<<"jabber:iq:register">>, __Opts, _el), Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"first">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, decode_register_first(<<"jabber:iq:register">>, __Opts, _el), Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"last">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, decode_register_last(<<"jabber:iq:register">>, __Opts, _el), First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"email">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, decode_register_email(<<"jabber:iq:register">>, __Opts, _el), __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"address">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, decode_register_address(<<"jabber:iq:register">>, __Opts, _el), Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"city">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, decode_register_city(<<"jabber:iq:register">>, __Opts, _el), Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"state">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, decode_register_state(<<"jabber:iq:register">>, __Opts, _el), Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"zip">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, decode_register_zip(<<"jabber:iq:register">>, __Opts, _el), Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"phone">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, decode_register_phone(<<"jabber:iq:register">>, __Opts, _el), State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"url">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, decode_register_url(<<"jabber:iq:register">>, __Opts, _el), Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"date">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, decode_register_date(<<"jabber:iq:register">>, __Opts, _el), Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"misc">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, decode_register_misc(<<"jabber:iq:register">>, __Opts, _el), Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"text">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, decode_register_text(<<"jabber:iq:register">>, __Opts, _el), Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, <<"key">>, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:register">> -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, decode_register_key(<<"jabber:iq:register">>, __Opts, _el), City, Nick, Url, Email, __Els); _ -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]) end; decode_register_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [_el | __Els]); Mod -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_register_els(__TopXMLNS, __Opts, [_ | _els], Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els) -> decode_register_els(__TopXMLNS, __Opts, _els, Zip, Xdata, Misc, Address, Instructions, Text, Last, First, Password, Registered, Date, Phone, State, Name, Username, Remove, Key, City, Nick, Url, Email, __Els). encode_register({register, Registered, Remove, Instructions, Username, Nick, Password, Name, First, Last, Email, Address, City, State, Zip, Phone, Url, Date, Misc, Text, Key, Xdata, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_register_$zip'(Zip, __NewTopXMLNS, 'encode_register_$xdata'(Xdata, __NewTopXMLNS, 'encode_register_$misc'(Misc, __NewTopXMLNS, 'encode_register_$address'(Address, __NewTopXMLNS, 'encode_register_$instructions'(Instructions, __NewTopXMLNS, 'encode_register_$text'(Text, __NewTopXMLNS, 'encode_register_$last'(Last, __NewTopXMLNS, 'encode_register_$first'(First, __NewTopXMLNS, 'encode_register_$password'(Password, __NewTopXMLNS, 'encode_register_$registered'(Registered, __NewTopXMLNS, 'encode_register_$date'(Date, __NewTopXMLNS, 'encode_register_$phone'(Phone, __NewTopXMLNS, 'encode_register_$state'(State, __NewTopXMLNS, 'encode_register_$name'(Name, __NewTopXMLNS, 'encode_register_$username'(Username, __NewTopXMLNS, 'encode_register_$remove'(Remove, __NewTopXMLNS, 'encode_register_$key'(Key, __NewTopXMLNS, 'encode_register_$city'(City, __NewTopXMLNS, 'encode_register_$nick'(Nick, __NewTopXMLNS, 'encode_register_$url'(Url, __NewTopXMLNS, 'encode_register_$email'(Email, __NewTopXMLNS, [])))))))))))))))))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. 'encode_register_$zip'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$zip'(Zip, __TopXMLNS, _acc) -> [encode_register_zip(Zip, __TopXMLNS) | _acc]. 'encode_register_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. 'encode_register_$misc'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$misc'(Misc, __TopXMLNS, _acc) -> [encode_register_misc(Misc, __TopXMLNS) | _acc]. 'encode_register_$address'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$address'(Address, __TopXMLNS, _acc) -> [encode_register_address(Address, __TopXMLNS) | _acc]. 'encode_register_$instructions'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$instructions'(Instructions, __TopXMLNS, _acc) -> [encode_register_instructions(Instructions, __TopXMLNS) | _acc]. 'encode_register_$text'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$text'(Text, __TopXMLNS, _acc) -> [encode_register_text(Text, __TopXMLNS) | _acc]. 'encode_register_$last'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$last'(Last, __TopXMLNS, _acc) -> [encode_register_last(Last, __TopXMLNS) | _acc]. 'encode_register_$first'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$first'(First, __TopXMLNS, _acc) -> [encode_register_first(First, __TopXMLNS) | _acc]. 'encode_register_$password'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$password'(Password, __TopXMLNS, _acc) -> [encode_register_password(Password, __TopXMLNS) | _acc]. 'encode_register_$registered'(false, __TopXMLNS, _acc) -> _acc; 'encode_register_$registered'(Registered, __TopXMLNS, _acc) -> [encode_register_registered(Registered, __TopXMLNS) | _acc]. 'encode_register_$date'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$date'(Date, __TopXMLNS, _acc) -> [encode_register_date(Date, __TopXMLNS) | _acc]. 'encode_register_$phone'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$phone'(Phone, __TopXMLNS, _acc) -> [encode_register_phone(Phone, __TopXMLNS) | _acc]. 'encode_register_$state'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$state'(State, __TopXMLNS, _acc) -> [encode_register_state(State, __TopXMLNS) | _acc]. 'encode_register_$name'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$name'(Name, __TopXMLNS, _acc) -> [encode_register_name(Name, __TopXMLNS) | _acc]. 'encode_register_$username'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$username'(Username, __TopXMLNS, _acc) -> [encode_register_username(Username, __TopXMLNS) | _acc]. 'encode_register_$remove'(false, __TopXMLNS, _acc) -> _acc; 'encode_register_$remove'(Remove, __TopXMLNS, _acc) -> [encode_register_remove(Remove, __TopXMLNS) | _acc]. 'encode_register_$key'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$key'(Key, __TopXMLNS, _acc) -> [encode_register_key(Key, __TopXMLNS) | _acc]. 'encode_register_$city'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$city'(City, __TopXMLNS, _acc) -> [encode_register_city(City, __TopXMLNS) | _acc]. 'encode_register_$nick'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$nick'(Nick, __TopXMLNS, _acc) -> [encode_register_nick(Nick, __TopXMLNS) | _acc]. 'encode_register_$url'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$url'(Url, __TopXMLNS, _acc) -> [encode_register_url(Url, __TopXMLNS) | _acc]. 'encode_register_$email'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_register_$email'(Email, __TopXMLNS, _acc) -> [encode_register_email(Email, __TopXMLNS) | _acc]. decode_register_key(__TopXMLNS, __Opts, {xmlel, <<"key">>, _attrs, _els}) -> Cdata = decode_register_key_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_key_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_key_cdata(__TopXMLNS, Cdata); decode_register_key_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_key_els(__TopXMLNS, __Opts, _els, <>); decode_register_key_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_key_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_key(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_key_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"key">>, _attrs, _els}. decode_register_key_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_key_cdata(__TopXMLNS, _val) -> _val. encode_register_key_cdata(<<>>, _acc) -> _acc; encode_register_key_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_text(__TopXMLNS, __Opts, {xmlel, <<"text">>, _attrs, _els}) -> Cdata = decode_register_text_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_text_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_text_cdata(__TopXMLNS, Cdata); decode_register_text_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_text_els(__TopXMLNS, __Opts, _els, <>); decode_register_text_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_text_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_text(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_text_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"text">>, _attrs, _els}. decode_register_text_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_text_cdata(__TopXMLNS, _val) -> _val. encode_register_text_cdata(<<>>, _acc) -> _acc; encode_register_text_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_misc(__TopXMLNS, __Opts, {xmlel, <<"misc">>, _attrs, _els}) -> Cdata = decode_register_misc_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_misc_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_misc_cdata(__TopXMLNS, Cdata); decode_register_misc_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_misc_els(__TopXMLNS, __Opts, _els, <>); decode_register_misc_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_misc_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_misc(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_misc_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"misc">>, _attrs, _els}. decode_register_misc_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_misc_cdata(__TopXMLNS, _val) -> _val. encode_register_misc_cdata(<<>>, _acc) -> _acc; encode_register_misc_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_date(__TopXMLNS, __Opts, {xmlel, <<"date">>, _attrs, _els}) -> Cdata = decode_register_date_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_date_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_date_cdata(__TopXMLNS, Cdata); decode_register_date_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_date_els(__TopXMLNS, __Opts, _els, <>); decode_register_date_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_date_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_date(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_date_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"date">>, _attrs, _els}. decode_register_date_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_date_cdata(__TopXMLNS, _val) -> _val. encode_register_date_cdata(<<>>, _acc) -> _acc; encode_register_date_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_url(__TopXMLNS, __Opts, {xmlel, <<"url">>, _attrs, _els}) -> Cdata = decode_register_url_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_url_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_url_cdata(__TopXMLNS, Cdata); decode_register_url_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_url_els(__TopXMLNS, __Opts, _els, <>); decode_register_url_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_url_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_url(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_url_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"url">>, _attrs, _els}. decode_register_url_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_url_cdata(__TopXMLNS, _val) -> _val. encode_register_url_cdata(<<>>, _acc) -> _acc; encode_register_url_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_phone(__TopXMLNS, __Opts, {xmlel, <<"phone">>, _attrs, _els}) -> Cdata = decode_register_phone_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_phone_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_phone_cdata(__TopXMLNS, Cdata); decode_register_phone_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_phone_els(__TopXMLNS, __Opts, _els, <>); decode_register_phone_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_phone_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_phone(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_phone_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"phone">>, _attrs, _els}. decode_register_phone_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_phone_cdata(__TopXMLNS, _val) -> _val. encode_register_phone_cdata(<<>>, _acc) -> _acc; encode_register_phone_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_zip(__TopXMLNS, __Opts, {xmlel, <<"zip">>, _attrs, _els}) -> Cdata = decode_register_zip_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_zip_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_zip_cdata(__TopXMLNS, Cdata); decode_register_zip_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_zip_els(__TopXMLNS, __Opts, _els, <>); decode_register_zip_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_zip_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_zip(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_zip_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"zip">>, _attrs, _els}. decode_register_zip_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_zip_cdata(__TopXMLNS, _val) -> _val. encode_register_zip_cdata(<<>>, _acc) -> _acc; encode_register_zip_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_state(__TopXMLNS, __Opts, {xmlel, <<"state">>, _attrs, _els}) -> Cdata = decode_register_state_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_state_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_state_cdata(__TopXMLNS, Cdata); decode_register_state_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_state_els(__TopXMLNS, __Opts, _els, <>); decode_register_state_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_state_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_state(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_state_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"state">>, _attrs, _els}. decode_register_state_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_state_cdata(__TopXMLNS, _val) -> _val. encode_register_state_cdata(<<>>, _acc) -> _acc; encode_register_state_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_city(__TopXMLNS, __Opts, {xmlel, <<"city">>, _attrs, _els}) -> Cdata = decode_register_city_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_city_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_city_cdata(__TopXMLNS, Cdata); decode_register_city_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_city_els(__TopXMLNS, __Opts, _els, <>); decode_register_city_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_city_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_city(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_city_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"city">>, _attrs, _els}. decode_register_city_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_city_cdata(__TopXMLNS, _val) -> _val. encode_register_city_cdata(<<>>, _acc) -> _acc; encode_register_city_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_address(__TopXMLNS, __Opts, {xmlel, <<"address">>, _attrs, _els}) -> Cdata = decode_register_address_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_address_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_address_cdata(__TopXMLNS, Cdata); decode_register_address_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_address_els(__TopXMLNS, __Opts, _els, <>); decode_register_address_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_address_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_address(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_address_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"address">>, _attrs, _els}. decode_register_address_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_address_cdata(__TopXMLNS, _val) -> _val. encode_register_address_cdata(<<>>, _acc) -> _acc; encode_register_address_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_email(__TopXMLNS, __Opts, {xmlel, <<"email">>, _attrs, _els}) -> Cdata = decode_register_email_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_email_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_email_cdata(__TopXMLNS, Cdata); decode_register_email_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_email_els(__TopXMLNS, __Opts, _els, <>); decode_register_email_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_email_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_email(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_email_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"email">>, _attrs, _els}. decode_register_email_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_email_cdata(__TopXMLNS, _val) -> _val. encode_register_email_cdata(<<>>, _acc) -> _acc; encode_register_email_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_last(__TopXMLNS, __Opts, {xmlel, <<"last">>, _attrs, _els}) -> Cdata = decode_register_last_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_last_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_last_cdata(__TopXMLNS, Cdata); decode_register_last_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_last_els(__TopXMLNS, __Opts, _els, <>); decode_register_last_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_last_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_last(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_last_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"last">>, _attrs, _els}. decode_register_last_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_last_cdata(__TopXMLNS, _val) -> _val. encode_register_last_cdata(<<>>, _acc) -> _acc; encode_register_last_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_first(__TopXMLNS, __Opts, {xmlel, <<"first">>, _attrs, _els}) -> Cdata = decode_register_first_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_first_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_first_cdata(__TopXMLNS, Cdata); decode_register_first_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_first_els(__TopXMLNS, __Opts, _els, <>); decode_register_first_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_first_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_first(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_first_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"first">>, _attrs, _els}. decode_register_first_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_first_cdata(__TopXMLNS, _val) -> _val. encode_register_first_cdata(<<>>, _acc) -> _acc; encode_register_first_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_name(__TopXMLNS, __Opts, {xmlel, <<"name">>, _attrs, _els}) -> Cdata = decode_register_name_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_name_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_name_cdata(__TopXMLNS, Cdata); decode_register_name_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_name_els(__TopXMLNS, __Opts, _els, <>); decode_register_name_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_name_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_name(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_name_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"name">>, _attrs, _els}. decode_register_name_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_name_cdata(__TopXMLNS, _val) -> _val. encode_register_name_cdata(<<>>, _acc) -> _acc; encode_register_name_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_password(__TopXMLNS, __Opts, {xmlel, <<"password">>, _attrs, _els}) -> Cdata = decode_register_password_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_password_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_password_cdata(__TopXMLNS, Cdata); decode_register_password_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_password_els(__TopXMLNS, __Opts, _els, <>); decode_register_password_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_password_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_password(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_password_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"password">>, _attrs, _els}. decode_register_password_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_password_cdata(__TopXMLNS, _val) -> _val. encode_register_password_cdata(<<>>, _acc) -> _acc; encode_register_password_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_nick(__TopXMLNS, __Opts, {xmlel, <<"nick">>, _attrs, _els}) -> Cdata = decode_register_nick_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_nick_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_nick_cdata(__TopXMLNS, Cdata); decode_register_nick_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_nick_els(__TopXMLNS, __Opts, _els, <>); decode_register_nick_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_nick_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_nick(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_nick_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"nick">>, _attrs, _els}. decode_register_nick_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_nick_cdata(__TopXMLNS, _val) -> _val. encode_register_nick_cdata(<<>>, _acc) -> _acc; encode_register_nick_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_username(__TopXMLNS, __Opts, {xmlel, <<"username">>, _attrs, _els}) -> Cdata = decode_register_username_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_username_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_username_cdata(__TopXMLNS, Cdata); decode_register_username_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_username_els(__TopXMLNS, __Opts, _els, <>); decode_register_username_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_username_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_username(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_username_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"username">>, _attrs, _els}. decode_register_username_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_username_cdata(__TopXMLNS, _val) -> _val. encode_register_username_cdata(<<>>, _acc) -> _acc; encode_register_username_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_instructions(__TopXMLNS, __Opts, {xmlel, <<"instructions">>, _attrs, _els}) -> Cdata = decode_register_instructions_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_register_instructions_els(__TopXMLNS, __Opts, [], Cdata) -> decode_register_instructions_cdata(__TopXMLNS, Cdata); decode_register_instructions_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_register_instructions_els(__TopXMLNS, __Opts, _els, <>); decode_register_instructions_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_register_instructions_els(__TopXMLNS, __Opts, _els, Cdata). encode_register_instructions(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = encode_register_instructions_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"instructions">>, _attrs, _els}. decode_register_instructions_cdata(__TopXMLNS, <<>>) -> <<>>; decode_register_instructions_cdata(__TopXMLNS, _val) -> _val. encode_register_instructions_cdata(<<>>, _acc) -> _acc; encode_register_instructions_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_register_remove(__TopXMLNS, __Opts, {xmlel, <<"remove">>, _attrs, _els}) -> true. encode_register_remove(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"remove">>, _attrs, _els}. decode_register_registered(__TopXMLNS, __Opts, {xmlel, <<"registered">>, _attrs, _els}) -> true. encode_register_registered(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:register">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"registered">>, _attrs, _els}. decode_feature_register(__TopXMLNS, __Opts, {xmlel, <<"register">>, _attrs, _els}) -> {feature_register}. encode_feature_register({feature_register}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/features/iq-register">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"register">>, _attrs, _els}. xmpp-1.4.4/src/xep0319.erl0000644000232200023220000000376613610066730015474 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0319). -compile(export_all). do_decode(<<"idle">>, <<"urn:xmpp:idle:1">>, El, Opts) -> decode_idle(<<"urn:xmpp:idle:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"idle">>, <<"urn:xmpp:idle:1">>}]. do_encode({idle, _} = Idle, TopXMLNS) -> encode_idle(Idle, TopXMLNS). do_get_name({idle, _}) -> <<"idle">>. do_get_ns({idle, _}) -> <<"urn:xmpp:idle:1">>. pp(idle, 1) -> [since]; pp(_, _) -> no. records() -> [{idle, 1}]. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_idle(__TopXMLNS, __Opts, {xmlel, <<"idle">>, _attrs, _els}) -> Since = decode_idle_attrs(__TopXMLNS, _attrs, undefined), {idle, Since}. decode_idle_attrs(__TopXMLNS, [{<<"since">>, _val} | _attrs], _Since) -> decode_idle_attrs(__TopXMLNS, _attrs, _val); decode_idle_attrs(__TopXMLNS, [_ | _attrs], Since) -> decode_idle_attrs(__TopXMLNS, _attrs, Since); decode_idle_attrs(__TopXMLNS, [], Since) -> decode_idle_attr_since(__TopXMLNS, Since). encode_idle({idle, Since}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:idle:1">>, [], __TopXMLNS), _els = [], _attrs = encode_idle_attr_since(Since, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"idle">>, _attrs, _els}. decode_idle_attr_since(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"since">>, <<"idle">>, __TopXMLNS}}); decode_idle_attr_since(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"since">>, <<"idle">>, __TopXMLNS}}); _res -> _res end. encode_idle_attr_since(_val, _acc) -> [{<<"since">>, enc_utc(_val)} | _acc]. xmpp-1.4.4/src/xep0359.erl0000644000232200023220000001002613610066730015463 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0359). -compile(export_all). do_decode(<<"origin-id">>, <<"urn:xmpp:sid:0">>, El, Opts) -> decode_origin_id(<<"urn:xmpp:sid:0">>, Opts, El); do_decode(<<"stanza-id">>, <<"urn:xmpp:sid:0">>, El, Opts) -> decode_stanza_id(<<"urn:xmpp:sid:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"origin-id">>, <<"urn:xmpp:sid:0">>}, {<<"stanza-id">>, <<"urn:xmpp:sid:0">>}]. do_encode({stanza_id, _, _} = Stanza_id, TopXMLNS) -> encode_stanza_id(Stanza_id, TopXMLNS); do_encode({origin_id, _} = Origin_id, TopXMLNS) -> encode_origin_id(Origin_id, TopXMLNS). do_get_name({origin_id, _}) -> <<"origin-id">>; do_get_name({stanza_id, _, _}) -> <<"stanza-id">>. do_get_ns({origin_id, _}) -> <<"urn:xmpp:sid:0">>; do_get_ns({stanza_id, _, _}) -> <<"urn:xmpp:sid:0">>. pp(stanza_id, 2) -> [by, id]; pp(origin_id, 1) -> [id]; pp(_, _) -> no. records() -> [{stanza_id, 2}, {origin_id, 1}]. decode_origin_id(__TopXMLNS, __Opts, {xmlel, <<"origin-id">>, _attrs, _els}) -> Id = decode_origin_id_attrs(__TopXMLNS, _attrs, undefined), {origin_id, Id}. decode_origin_id_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id) -> decode_origin_id_attrs(__TopXMLNS, _attrs, _val); decode_origin_id_attrs(__TopXMLNS, [_ | _attrs], Id) -> decode_origin_id_attrs(__TopXMLNS, _attrs, Id); decode_origin_id_attrs(__TopXMLNS, [], Id) -> decode_origin_id_attr_id(__TopXMLNS, Id). encode_origin_id({origin_id, Id}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:sid:0">>, [], __TopXMLNS), _els = [], _attrs = encode_origin_id_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"origin-id">>, _attrs, _els}. decode_origin_id_attr_id(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"id">>, <<"origin-id">>, __TopXMLNS}}); decode_origin_id_attr_id(__TopXMLNS, _val) -> _val. encode_origin_id_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_stanza_id(__TopXMLNS, __Opts, {xmlel, <<"stanza-id">>, _attrs, _els}) -> {Id, By} = decode_stanza_id_attrs(__TopXMLNS, _attrs, undefined, undefined), {stanza_id, By, Id}. decode_stanza_id_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, By) -> decode_stanza_id_attrs(__TopXMLNS, _attrs, _val, By); decode_stanza_id_attrs(__TopXMLNS, [{<<"by">>, _val} | _attrs], Id, _By) -> decode_stanza_id_attrs(__TopXMLNS, _attrs, Id, _val); decode_stanza_id_attrs(__TopXMLNS, [_ | _attrs], Id, By) -> decode_stanza_id_attrs(__TopXMLNS, _attrs, Id, By); decode_stanza_id_attrs(__TopXMLNS, [], Id, By) -> {decode_stanza_id_attr_id(__TopXMLNS, Id), decode_stanza_id_attr_by(__TopXMLNS, By)}. encode_stanza_id({stanza_id, By, Id}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:sid:0">>, [], __TopXMLNS), _els = [], _attrs = encode_stanza_id_attr_by(By, encode_stanza_id_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"stanza-id">>, _attrs, _els}. decode_stanza_id_attr_id(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"id">>, <<"stanza-id">>, __TopXMLNS}}); decode_stanza_id_attr_id(__TopXMLNS, _val) -> _val. encode_stanza_id_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_stanza_id_attr_by(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"by">>, <<"stanza-id">>, __TopXMLNS}}); decode_stanza_id_attr_by(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"by">>, <<"stanza-id">>, __TopXMLNS}}); _res -> _res end. encode_stanza_id_attr_by(_val, _acc) -> [{<<"by">>, jid:encode(_val)} | _acc]. xmpp-1.4.4/src/xep0234.erl0000644000232200023220000010527213610066730015463 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0234). -compile(export_all). do_decode(<<"file-too-large">>, <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, El, Opts) -> decode_jingle_ft_error_file_too_large(<<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, Opts, El); do_decode(<<"file-not-available">>, <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, El, Opts) -> decode_jingle_ft_error_file_not_available(<<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, Opts, El); do_decode(<<"checksum">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_checksum(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"received">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_received(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"description">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_description(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"file">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_file(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"range">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_range(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"size">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_size(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"name">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_name(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"media-type">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_media_type(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"desc">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_desc(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(<<"date">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>, El, Opts) -> decode_jingle_ft_date(<<"urn:xmpp:jingle:apps:file-transfer:5">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"file-too-large">>, <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>}, {<<"file-not-available">>, <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>}, {<<"checksum">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"received">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"description">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"file">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"range">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"size">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"name">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"media-type">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"desc">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}, {<<"date">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>}]. do_encode({text, _, _} = Desc, TopXMLNS) -> encode_jingle_ft_desc(Desc, TopXMLNS); do_encode({jingle_ft_range, _, _, _} = Range, TopXMLNS) -> encode_jingle_ft_range(Range, TopXMLNS); do_encode({jingle_ft_file, _, _, _, _, _, _, _, _} = File, TopXMLNS) -> encode_jingle_ft_file(File, TopXMLNS); do_encode({jingle_ft_description, _} = Description, TopXMLNS) -> encode_jingle_ft_description(Description, TopXMLNS); do_encode({jingle_ft_received, _, _} = Received, TopXMLNS) -> encode_jingle_ft_received(Received, TopXMLNS); do_encode({jingle_ft_checksum, _, _, _} = Checksum, TopXMLNS) -> encode_jingle_ft_checksum(Checksum, TopXMLNS); do_encode({jingle_ft_error, 'file-not-available'} = File_not_available, TopXMLNS) -> encode_jingle_ft_error_file_not_available(File_not_available, TopXMLNS); do_encode({jingle_ft_error, 'file-too-large'} = File_too_large, TopXMLNS) -> encode_jingle_ft_error_file_too_large(File_too_large, TopXMLNS). do_get_name({jingle_ft_checksum, _, _, _}) -> <<"checksum">>; do_get_name({jingle_ft_description, _}) -> <<"description">>; do_get_name({jingle_ft_error, 'file-not-available'}) -> <<"file-not-available">>; do_get_name({jingle_ft_error, 'file-too-large'}) -> <<"file-too-large">>; do_get_name({jingle_ft_file, _, _, _, _, _, _, _, _}) -> <<"file">>; do_get_name({jingle_ft_range, _, _, _}) -> <<"range">>; do_get_name({jingle_ft_received, _, _}) -> <<"received">>; do_get_name({text, _, _}) -> <<"desc">>. do_get_ns({jingle_ft_checksum, _, _, _}) -> <<"urn:xmpp:jingle:apps:file-transfer:5">>; do_get_ns({jingle_ft_description, _}) -> <<"urn:xmpp:jingle:apps:file-transfer:5">>; do_get_ns({jingle_ft_error, 'file-not-available'}) -> <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>; do_get_ns({jingle_ft_error, 'file-too-large'}) -> <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>; do_get_ns({jingle_ft_file, _, _, _, _, _, _, _, _}) -> <<"urn:xmpp:jingle:apps:file-transfer:5">>; do_get_ns({jingle_ft_range, _, _, _}) -> <<"urn:xmpp:jingle:apps:file-transfer:5">>; do_get_ns({jingle_ft_received, _, _}) -> <<"urn:xmpp:jingle:apps:file-transfer:5">>; do_get_ns({text, _, _}) -> <<"urn:xmpp:jingle:apps:file-transfer:5">>. pp(text, 2) -> [lang, data]; pp(jingle_ft_range, 3) -> [offset, length, hash]; pp(jingle_ft_file, 8) -> [date, desc, hash, 'hash-used', 'media-type', name, size, range]; pp(jingle_ft_description, 1) -> [file]; pp(jingle_ft_received, 2) -> [creator, name]; pp(jingle_ft_checksum, 3) -> [creator, name, file]; pp(jingle_ft_error, 1) -> [reason]; pp(_, _) -> no. records() -> [{text, 2}, {jingle_ft_range, 3}, {jingle_ft_file, 8}, {jingle_ft_description, 1}, {jingle_ft_received, 2}, {jingle_ft_checksum, 3}, {jingle_ft_error, 1}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_jingle_ft_error_file_too_large(__TopXMLNS, __Opts, {xmlel, <<"file-too-large">>, _attrs, _els}) -> {jingle_ft_error, 'file-too-large'}. encode_jingle_ft_error_file_too_large({jingle_ft_error, 'file-too-large'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"file-too-large">>, _attrs, _els}. decode_jingle_ft_error_file_not_available(__TopXMLNS, __Opts, {xmlel, <<"file-not-available">>, _attrs, _els}) -> {jingle_ft_error, 'file-not-available'}. encode_jingle_ft_error_file_not_available({jingle_ft_error, 'file-not-available'}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:errors:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"file-not-available">>, _attrs, _els}. decode_jingle_ft_checksum(__TopXMLNS, __Opts, {xmlel, <<"checksum">>, _attrs, _els}) -> File = decode_jingle_ft_checksum_els(__TopXMLNS, __Opts, _els, error), {Creator, Name} = decode_jingle_ft_checksum_attrs(__TopXMLNS, _attrs, undefined, undefined), {jingle_ft_checksum, Creator, Name, File}. decode_jingle_ft_checksum_els(__TopXMLNS, __Opts, [], File) -> case File of error -> erlang:error({xmpp_codec, {missing_tag, <<"file">>, __TopXMLNS}}); {value, File1} -> File1 end; decode_jingle_ft_checksum_els(__TopXMLNS, __Opts, [{xmlel, <<"file">>, _attrs, _} = _el | _els], File) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_checksum_els(__TopXMLNS, __Opts, _els, {value, decode_jingle_ft_file(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el)}); _ -> decode_jingle_ft_checksum_els(__TopXMLNS, __Opts, _els, File) end; decode_jingle_ft_checksum_els(__TopXMLNS, __Opts, [_ | _els], File) -> decode_jingle_ft_checksum_els(__TopXMLNS, __Opts, _els, File). decode_jingle_ft_checksum_attrs(__TopXMLNS, [{<<"creator">>, _val} | _attrs], _Creator, Name) -> decode_jingle_ft_checksum_attrs(__TopXMLNS, _attrs, _val, Name); decode_jingle_ft_checksum_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], Creator, _Name) -> decode_jingle_ft_checksum_attrs(__TopXMLNS, _attrs, Creator, _val); decode_jingle_ft_checksum_attrs(__TopXMLNS, [_ | _attrs], Creator, Name) -> decode_jingle_ft_checksum_attrs(__TopXMLNS, _attrs, Creator, Name); decode_jingle_ft_checksum_attrs(__TopXMLNS, [], Creator, Name) -> {decode_jingle_ft_checksum_attr_creator(__TopXMLNS, Creator), decode_jingle_ft_checksum_attr_name(__TopXMLNS, Name)}. encode_jingle_ft_checksum({jingle_ft_checksum, Creator, Name, File}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = lists:reverse('encode_jingle_ft_checksum_$file'(File, __NewTopXMLNS, [])), _attrs = encode_jingle_ft_checksum_attr_name(Name, encode_jingle_ft_checksum_attr_creator(Creator, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"checksum">>, _attrs, _els}. 'encode_jingle_ft_checksum_$file'(File, __TopXMLNS, _acc) -> [encode_jingle_ft_file(File, __TopXMLNS) | _acc]. decode_jingle_ft_checksum_attr_creator(__TopXMLNS, undefined) -> undefined; decode_jingle_ft_checksum_attr_creator(__TopXMLNS, _val) -> case catch dec_enum(_val, [initiator, responder]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"creator">>, <<"checksum">>, __TopXMLNS}}); _res -> _res end. encode_jingle_ft_checksum_attr_creator(undefined, _acc) -> _acc; encode_jingle_ft_checksum_attr_creator(_val, _acc) -> [{<<"creator">>, enc_enum(_val)} | _acc]. decode_jingle_ft_checksum_attr_name(__TopXMLNS, undefined) -> <<>>; decode_jingle_ft_checksum_attr_name(__TopXMLNS, _val) -> _val. encode_jingle_ft_checksum_attr_name(<<>>, _acc) -> _acc; encode_jingle_ft_checksum_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_jingle_ft_received(__TopXMLNS, __Opts, {xmlel, <<"received">>, _attrs, _els}) -> {Creator, Name} = decode_jingle_ft_received_attrs(__TopXMLNS, _attrs, undefined, undefined), {jingle_ft_received, Creator, Name}. decode_jingle_ft_received_attrs(__TopXMLNS, [{<<"creator">>, _val} | _attrs], _Creator, Name) -> decode_jingle_ft_received_attrs(__TopXMLNS, _attrs, _val, Name); decode_jingle_ft_received_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], Creator, _Name) -> decode_jingle_ft_received_attrs(__TopXMLNS, _attrs, Creator, _val); decode_jingle_ft_received_attrs(__TopXMLNS, [_ | _attrs], Creator, Name) -> decode_jingle_ft_received_attrs(__TopXMLNS, _attrs, Creator, Name); decode_jingle_ft_received_attrs(__TopXMLNS, [], Creator, Name) -> {decode_jingle_ft_received_attr_creator(__TopXMLNS, Creator), decode_jingle_ft_received_attr_name(__TopXMLNS, Name)}. encode_jingle_ft_received({jingle_ft_received, Creator, Name}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = [], _attrs = encode_jingle_ft_received_attr_name(Name, encode_jingle_ft_received_attr_creator(Creator, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"received">>, _attrs, _els}. decode_jingle_ft_received_attr_creator(__TopXMLNS, undefined) -> undefined; decode_jingle_ft_received_attr_creator(__TopXMLNS, _val) -> case catch dec_enum(_val, [initiator, responder]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"creator">>, <<"received">>, __TopXMLNS}}); _res -> _res end. encode_jingle_ft_received_attr_creator(undefined, _acc) -> _acc; encode_jingle_ft_received_attr_creator(_val, _acc) -> [{<<"creator">>, enc_enum(_val)} | _acc]. decode_jingle_ft_received_attr_name(__TopXMLNS, undefined) -> <<>>; decode_jingle_ft_received_attr_name(__TopXMLNS, _val) -> _val. encode_jingle_ft_received_attr_name(<<>>, _acc) -> _acc; encode_jingle_ft_received_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_jingle_ft_description(__TopXMLNS, __Opts, {xmlel, <<"description">>, _attrs, _els}) -> File = decode_jingle_ft_description_els(__TopXMLNS, __Opts, _els, undefined), {jingle_ft_description, File}. decode_jingle_ft_description_els(__TopXMLNS, __Opts, [], File) -> File; decode_jingle_ft_description_els(__TopXMLNS, __Opts, [{xmlel, <<"file">>, _attrs, _} = _el | _els], File) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_description_els(__TopXMLNS, __Opts, _els, decode_jingle_ft_file(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el)); _ -> decode_jingle_ft_description_els(__TopXMLNS, __Opts, _els, File) end; decode_jingle_ft_description_els(__TopXMLNS, __Opts, [_ | _els], File) -> decode_jingle_ft_description_els(__TopXMLNS, __Opts, _els, File). encode_jingle_ft_description({jingle_ft_description, File}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = lists:reverse('encode_jingle_ft_description_$file'(File, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"description">>, _attrs, _els}. 'encode_jingle_ft_description_$file'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_description_$file'(File, __TopXMLNS, _acc) -> [encode_jingle_ft_file(File, __TopXMLNS) | _acc]. decode_jingle_ft_file(__TopXMLNS, __Opts, {xmlel, <<"file">>, _attrs, _els}) -> {Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash} = decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, [], undefined, undefined, undefined, undefined, undefined, undefined, []), {jingle_ft_file, Date, Desc, Hash, Hash_used, Media_type, Name, Size, Range}. decode_jingle_ft_file_els(__TopXMLNS, __Opts, [], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> {lists:reverse(Desc), Hash_used, Range, Size, Name, Media_type, Date, lists:reverse(Hash)}; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"date">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, decode_jingle_ft_date(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el), Hash); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"desc">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, [decode_jingle_ft_desc(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el) | Desc], Hash_used, Range, Size, Name, Media_type, Date, Hash); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"hash">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:hashes:2">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, [xep0300:decode_hash(<<"urn:xmpp:hashes:2">>, __Opts, _el) | Hash]); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"hash-used">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:hashes:2">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, xep0300:decode_hash_used(<<"urn:xmpp:hashes:2">>, __Opts, _el), Range, Size, Name, Media_type, Date, Hash); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"media-type">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, decode_jingle_ft_media_type(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el), Date, Hash); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"name">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, decode_jingle_ft_name(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el), Media_type, Date, Hash); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"size">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, decode_jingle_ft_size(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el), Name, Media_type, Date, Hash); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [{xmlel, <<"range">>, _attrs, _} = _el | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:jingle:apps:file-transfer:5">> -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, decode_jingle_ft_range(<<"urn:xmpp:jingle:apps:file-transfer:5">>, __Opts, _el), Size, Name, Media_type, Date, Hash); _ -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) end; decode_jingle_ft_file_els(__TopXMLNS, __Opts, [_ | _els], Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash) -> decode_jingle_ft_file_els(__TopXMLNS, __Opts, _els, Desc, Hash_used, Range, Size, Name, Media_type, Date, Hash). encode_jingle_ft_file({jingle_ft_file, Date, Desc, Hash, Hash_used, Media_type, Name, Size, Range}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = lists:reverse('encode_jingle_ft_file_$desc'(Desc, __NewTopXMLNS, 'encode_jingle_ft_file_$hash-used'(Hash_used, __NewTopXMLNS, 'encode_jingle_ft_file_$range'(Range, __NewTopXMLNS, 'encode_jingle_ft_file_$size'(Size, __NewTopXMLNS, 'encode_jingle_ft_file_$name'(Name, __NewTopXMLNS, 'encode_jingle_ft_file_$media-type'(Media_type, __NewTopXMLNS, 'encode_jingle_ft_file_$date'(Date, __NewTopXMLNS, 'encode_jingle_ft_file_$hash'(Hash, __NewTopXMLNS, []))))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"file">>, _attrs, _els}. 'encode_jingle_ft_file_$desc'([], __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$desc'([Desc | _els], __TopXMLNS, _acc) -> 'encode_jingle_ft_file_$desc'(_els, __TopXMLNS, [encode_jingle_ft_desc(Desc, __TopXMLNS) | _acc]). 'encode_jingle_ft_file_$hash-used'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$hash-used'(Hash_used, __TopXMLNS, _acc) -> [xep0300:encode_hash_used(Hash_used, __TopXMLNS) | _acc]. 'encode_jingle_ft_file_$range'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$range'(Range, __TopXMLNS, _acc) -> [encode_jingle_ft_range(Range, __TopXMLNS) | _acc]. 'encode_jingle_ft_file_$size'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$size'(Size, __TopXMLNS, _acc) -> [encode_jingle_ft_size(Size, __TopXMLNS) | _acc]. 'encode_jingle_ft_file_$name'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$name'(Name, __TopXMLNS, _acc) -> [encode_jingle_ft_name(Name, __TopXMLNS) | _acc]. 'encode_jingle_ft_file_$media-type'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$media-type'(Media_type, __TopXMLNS, _acc) -> [encode_jingle_ft_media_type(Media_type, __TopXMLNS) | _acc]. 'encode_jingle_ft_file_$date'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$date'(Date, __TopXMLNS, _acc) -> [encode_jingle_ft_date(Date, __TopXMLNS) | _acc]. 'encode_jingle_ft_file_$hash'([], __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_file_$hash'([Hash | _els], __TopXMLNS, _acc) -> 'encode_jingle_ft_file_$hash'(_els, __TopXMLNS, [xep0300:encode_hash(Hash, __TopXMLNS) | _acc]). decode_jingle_ft_range(__TopXMLNS, __Opts, {xmlel, <<"range">>, _attrs, _els}) -> Hash = decode_jingle_ft_range_els(__TopXMLNS, __Opts, _els, []), {Offset, Length} = decode_jingle_ft_range_attrs(__TopXMLNS, _attrs, undefined, undefined), {jingle_ft_range, Offset, Length, Hash}. decode_jingle_ft_range_els(__TopXMLNS, __Opts, [], Hash) -> lists:reverse(Hash); decode_jingle_ft_range_els(__TopXMLNS, __Opts, [{xmlel, <<"hash">>, _attrs, _} = _el | _els], Hash) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:hashes:2">> -> decode_jingle_ft_range_els(__TopXMLNS, __Opts, _els, [xep0300:decode_hash(<<"urn:xmpp:hashes:2">>, __Opts, _el) | Hash]); _ -> decode_jingle_ft_range_els(__TopXMLNS, __Opts, _els, Hash) end; decode_jingle_ft_range_els(__TopXMLNS, __Opts, [_ | _els], Hash) -> decode_jingle_ft_range_els(__TopXMLNS, __Opts, _els, Hash). decode_jingle_ft_range_attrs(__TopXMLNS, [{<<"offset">>, _val} | _attrs], _Offset, Length) -> decode_jingle_ft_range_attrs(__TopXMLNS, _attrs, _val, Length); decode_jingle_ft_range_attrs(__TopXMLNS, [{<<"length">>, _val} | _attrs], Offset, _Length) -> decode_jingle_ft_range_attrs(__TopXMLNS, _attrs, Offset, _val); decode_jingle_ft_range_attrs(__TopXMLNS, [_ | _attrs], Offset, Length) -> decode_jingle_ft_range_attrs(__TopXMLNS, _attrs, Offset, Length); decode_jingle_ft_range_attrs(__TopXMLNS, [], Offset, Length) -> {decode_jingle_ft_range_attr_offset(__TopXMLNS, Offset), decode_jingle_ft_range_attr_length(__TopXMLNS, Length)}. encode_jingle_ft_range({jingle_ft_range, Offset, Length, Hash}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = lists:reverse('encode_jingle_ft_range_$hash'(Hash, __NewTopXMLNS, [])), _attrs = encode_jingle_ft_range_attr_length(Length, encode_jingle_ft_range_attr_offset(Offset, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"range">>, _attrs, _els}. 'encode_jingle_ft_range_$hash'([], __TopXMLNS, _acc) -> _acc; 'encode_jingle_ft_range_$hash'([Hash | _els], __TopXMLNS, _acc) -> 'encode_jingle_ft_range_$hash'(_els, __TopXMLNS, [xep0300:encode_hash(Hash, __TopXMLNS) | _acc]). decode_jingle_ft_range_attr_offset(__TopXMLNS, undefined) -> 0; decode_jingle_ft_range_attr_offset(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"offset">>, <<"range">>, __TopXMLNS}}); _res -> _res end. encode_jingle_ft_range_attr_offset(0, _acc) -> _acc; encode_jingle_ft_range_attr_offset(_val, _acc) -> [{<<"offset">>, enc_int(_val)} | _acc]. decode_jingle_ft_range_attr_length(__TopXMLNS, undefined) -> undefined; decode_jingle_ft_range_attr_length(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"length">>, <<"range">>, __TopXMLNS}}); _res -> _res end. encode_jingle_ft_range_attr_length(undefined, _acc) -> _acc; encode_jingle_ft_range_attr_length(_val, _acc) -> [{<<"length">>, enc_int(_val)} | _acc]. decode_jingle_ft_size(__TopXMLNS, __Opts, {xmlel, <<"size">>, _attrs, _els}) -> Cdata = decode_jingle_ft_size_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_jingle_ft_size_els(__TopXMLNS, __Opts, [], Cdata) -> decode_jingle_ft_size_cdata(__TopXMLNS, Cdata); decode_jingle_ft_size_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_jingle_ft_size_els(__TopXMLNS, __Opts, _els, <>); decode_jingle_ft_size_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_jingle_ft_size_els(__TopXMLNS, __Opts, _els, Cdata). encode_jingle_ft_size(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = encode_jingle_ft_size_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"size">>, _attrs, _els}. decode_jingle_ft_size_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"size">>, __TopXMLNS}}); decode_jingle_ft_size_cdata(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"size">>, __TopXMLNS}}); _res -> _res end. encode_jingle_ft_size_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_jingle_ft_name(__TopXMLNS, __Opts, {xmlel, <<"name">>, _attrs, _els}) -> Cdata = decode_jingle_ft_name_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_jingle_ft_name_els(__TopXMLNS, __Opts, [], Cdata) -> decode_jingle_ft_name_cdata(__TopXMLNS, Cdata); decode_jingle_ft_name_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_jingle_ft_name_els(__TopXMLNS, __Opts, _els, <>); decode_jingle_ft_name_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_jingle_ft_name_els(__TopXMLNS, __Opts, _els, Cdata). encode_jingle_ft_name(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = encode_jingle_ft_name_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"name">>, _attrs, _els}. decode_jingle_ft_name_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"name">>, __TopXMLNS}}); decode_jingle_ft_name_cdata(__TopXMLNS, _val) -> _val. encode_jingle_ft_name_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_jingle_ft_media_type(__TopXMLNS, __Opts, {xmlel, <<"media-type">>, _attrs, _els}) -> Cdata = decode_jingle_ft_media_type_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_jingle_ft_media_type_els(__TopXMLNS, __Opts, [], Cdata) -> decode_jingle_ft_media_type_cdata(__TopXMLNS, Cdata); decode_jingle_ft_media_type_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_jingle_ft_media_type_els(__TopXMLNS, __Opts, _els, <>); decode_jingle_ft_media_type_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_jingle_ft_media_type_els(__TopXMLNS, __Opts, _els, Cdata). encode_jingle_ft_media_type(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = encode_jingle_ft_media_type_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"media-type">>, _attrs, _els}. decode_jingle_ft_media_type_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"media-type">>, __TopXMLNS}}); decode_jingle_ft_media_type_cdata(__TopXMLNS, _val) -> _val. encode_jingle_ft_media_type_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_jingle_ft_desc(__TopXMLNS, __Opts, {xmlel, <<"desc">>, _attrs, _els}) -> Data = decode_jingle_ft_desc_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_jingle_ft_desc_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_jingle_ft_desc_els(__TopXMLNS, __Opts, [], Data) -> decode_jingle_ft_desc_cdata(__TopXMLNS, Data); decode_jingle_ft_desc_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_jingle_ft_desc_els(__TopXMLNS, __Opts, _els, <>); decode_jingle_ft_desc_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_jingle_ft_desc_els(__TopXMLNS, __Opts, _els, Data). decode_jingle_ft_desc_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_jingle_ft_desc_attrs(__TopXMLNS, _attrs, _val); decode_jingle_ft_desc_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_jingle_ft_desc_attrs(__TopXMLNS, _attrs, Lang); decode_jingle_ft_desc_attrs(__TopXMLNS, [], Lang) -> 'decode_jingle_ft_desc_attr_xml:lang'(__TopXMLNS, Lang). encode_jingle_ft_desc({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = encode_jingle_ft_desc_cdata(Data, []), _attrs = 'encode_jingle_ft_desc_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"desc">>, _attrs, _els}. 'decode_jingle_ft_desc_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_jingle_ft_desc_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"desc">>, __TopXMLNS}}); _res -> _res end. 'encode_jingle_ft_desc_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_jingle_ft_desc_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_jingle_ft_desc_cdata(__TopXMLNS, <<>>) -> <<>>; decode_jingle_ft_desc_cdata(__TopXMLNS, _val) -> _val. encode_jingle_ft_desc_cdata(<<>>, _acc) -> _acc; encode_jingle_ft_desc_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_jingle_ft_date(__TopXMLNS, __Opts, {xmlel, <<"date">>, _attrs, _els}) -> Cdata = decode_jingle_ft_date_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_jingle_ft_date_els(__TopXMLNS, __Opts, [], Cdata) -> decode_jingle_ft_date_cdata(__TopXMLNS, Cdata); decode_jingle_ft_date_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_jingle_ft_date_els(__TopXMLNS, __Opts, _els, <>); decode_jingle_ft_date_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_jingle_ft_date_els(__TopXMLNS, __Opts, _els, Cdata). encode_jingle_ft_date(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jingle:apps:file-transfer:5">>, [], __TopXMLNS), _els = encode_jingle_ft_date_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"date">>, _attrs, _els}. decode_jingle_ft_date_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"date">>, __TopXMLNS}}); decode_jingle_ft_date_cdata(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"date">>, __TopXMLNS}}); _res -> _res end. encode_jingle_ft_date_cdata(_val, _acc) -> [{xmlcdata, enc_utc(_val)} | _acc]. xmpp-1.4.4/src/xep0369.erl0000644000232200023220000005335413610066730015477 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0369). -compile(export_all). do_decode(<<"mix">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"destroy">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_destroy(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"create">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_create(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"participant">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_participant(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"leave">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_leave(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"join">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_join(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"setnick">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_setnick(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"submission-id">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_submission_id(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"jid">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_jid(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"nick">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_nick(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(<<"subscribe">>, <<"urn:xmpp:mix:core:0">>, El, Opts) -> decode_mix_subscribe(<<"urn:xmpp:mix:core:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"mix">>, <<"urn:xmpp:mix:core:0">>}, {<<"destroy">>, <<"urn:xmpp:mix:core:0">>}, {<<"create">>, <<"urn:xmpp:mix:core:0">>}, {<<"participant">>, <<"urn:xmpp:mix:core:0">>}, {<<"leave">>, <<"urn:xmpp:mix:core:0">>}, {<<"join">>, <<"urn:xmpp:mix:core:0">>}, {<<"setnick">>, <<"urn:xmpp:mix:core:0">>}, {<<"submission-id">>, <<"urn:xmpp:mix:core:0">>}, {<<"jid">>, <<"urn:xmpp:mix:core:0">>}, {<<"nick">>, <<"urn:xmpp:mix:core:0">>}, {<<"subscribe">>, <<"urn:xmpp:mix:core:0">>}]. do_encode({mix_setnick, _} = Setnick, TopXMLNS) -> encode_mix_setnick(Setnick, TopXMLNS); do_encode({mix_join, _, _, _, _} = Join, TopXMLNS) -> encode_mix_join(Join, TopXMLNS); do_encode({mix_leave} = Leave, TopXMLNS) -> encode_mix_leave(Leave, TopXMLNS); do_encode({mix_participant, _, _} = Participant, TopXMLNS) -> encode_mix_participant(Participant, TopXMLNS); do_encode({mix_create, _} = Create, TopXMLNS) -> encode_mix_create(Create, TopXMLNS); do_encode({mix_destroy, _} = Destroy, TopXMLNS) -> encode_mix_destroy(Destroy, TopXMLNS); do_encode({mix, _, _, _} = Mix, TopXMLNS) -> encode_mix(Mix, TopXMLNS). do_get_name({mix, _, _, _}) -> <<"mix">>; do_get_name({mix_create, _}) -> <<"create">>; do_get_name({mix_destroy, _}) -> <<"destroy">>; do_get_name({mix_join, _, _, _, _}) -> <<"join">>; do_get_name({mix_leave}) -> <<"leave">>; do_get_name({mix_participant, _, _}) -> <<"participant">>; do_get_name({mix_setnick, _}) -> <<"setnick">>. do_get_ns({mix, _, _, _}) -> <<"urn:xmpp:mix:core:0">>; do_get_ns({mix_create, _}) -> <<"urn:xmpp:mix:core:0">>; do_get_ns({mix_destroy, _}) -> <<"urn:xmpp:mix:core:0">>; do_get_ns({mix_join, _, _, _, _}) -> <<"urn:xmpp:mix:core:0">>; do_get_ns({mix_leave}) -> <<"urn:xmpp:mix:core:0">>; do_get_ns({mix_participant, _, _}) -> <<"urn:xmpp:mix:core:0">>; do_get_ns({mix_setnick, _}) -> <<"urn:xmpp:mix:core:0">>. pp(mix_setnick, 1) -> [nick]; pp(mix_join, 4) -> [id, jid, nick, subscribe]; pp(mix_leave, 0) -> []; pp(mix_participant, 2) -> [jid, nick]; pp(mix_create, 1) -> [channel]; pp(mix_destroy, 1) -> [channel]; pp(mix, 3) -> [submission_id, jid, nick]; pp(_, _) -> no. records() -> [{mix_setnick, 1}, {mix_join, 4}, {mix_leave, 0}, {mix_participant, 2}, {mix_create, 1}, {mix_destroy, 1}, {mix, 3}]. nodeprep(S) -> case jid:nodeprep(S) of error -> erlang:error(badarg); S1 -> S1 end. decode_mix(__TopXMLNS, __Opts, {xmlel, <<"mix">>, _attrs, _els}) -> {Jid, Submission_id, Nick} = decode_mix_els(__TopXMLNS, __Opts, _els, undefined, <<>>, <<>>), {mix, Submission_id, Jid, Nick}. decode_mix_els(__TopXMLNS, __Opts, [], Jid, Submission_id, Nick) -> {Jid, Submission_id, Nick}; decode_mix_els(__TopXMLNS, __Opts, [{xmlel, <<"submission-id">>, _attrs, _} = _el | _els], Jid, Submission_id, Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_els(__TopXMLNS, __Opts, _els, Jid, decode_mix_submission_id(<<"urn:xmpp:mix:core:0">>, __Opts, _el), Nick); _ -> decode_mix_els(__TopXMLNS, __Opts, _els, Jid, Submission_id, Nick) end; decode_mix_els(__TopXMLNS, __Opts, [{xmlel, <<"jid">>, _attrs, _} = _el | _els], Jid, Submission_id, Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_els(__TopXMLNS, __Opts, _els, decode_mix_jid(<<"urn:xmpp:mix:core:0">>, __Opts, _el), Submission_id, Nick); _ -> decode_mix_els(__TopXMLNS, __Opts, _els, Jid, Submission_id, Nick) end; decode_mix_els(__TopXMLNS, __Opts, [{xmlel, <<"nick">>, _attrs, _} = _el | _els], Jid, Submission_id, Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_els(__TopXMLNS, __Opts, _els, Jid, Submission_id, decode_mix_nick(<<"urn:xmpp:mix:core:0">>, __Opts, _el)); _ -> decode_mix_els(__TopXMLNS, __Opts, _els, Jid, Submission_id, Nick) end; decode_mix_els(__TopXMLNS, __Opts, [_ | _els], Jid, Submission_id, Nick) -> decode_mix_els(__TopXMLNS, __Opts, _els, Jid, Submission_id, Nick). encode_mix({mix, Submission_id, Jid, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = lists:reverse('encode_mix_$jid'(Jid, __NewTopXMLNS, 'encode_mix_$submission_id'(Submission_id, __NewTopXMLNS, 'encode_mix_$nick'(Nick, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"mix">>, _attrs, _els}. 'encode_mix_$jid'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mix_$jid'(Jid, __TopXMLNS, _acc) -> [encode_mix_jid(Jid, __TopXMLNS) | _acc]. 'encode_mix_$submission_id'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_mix_$submission_id'(Submission_id, __TopXMLNS, _acc) -> [encode_mix_submission_id(Submission_id, __TopXMLNS) | _acc]. 'encode_mix_$nick'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_mix_$nick'(Nick, __TopXMLNS, _acc) -> [encode_mix_nick(Nick, __TopXMLNS) | _acc]. decode_mix_destroy(__TopXMLNS, __Opts, {xmlel, <<"destroy">>, _attrs, _els}) -> Channel = decode_mix_destroy_attrs(__TopXMLNS, _attrs, undefined), {mix_destroy, Channel}. decode_mix_destroy_attrs(__TopXMLNS, [{<<"channel">>, _val} | _attrs], _Channel) -> decode_mix_destroy_attrs(__TopXMLNS, _attrs, _val); decode_mix_destroy_attrs(__TopXMLNS, [_ | _attrs], Channel) -> decode_mix_destroy_attrs(__TopXMLNS, _attrs, Channel); decode_mix_destroy_attrs(__TopXMLNS, [], Channel) -> decode_mix_destroy_attr_channel(__TopXMLNS, Channel). encode_mix_destroy({mix_destroy, Channel}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = [], _attrs = encode_mix_destroy_attr_channel(Channel, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"destroy">>, _attrs, _els}. decode_mix_destroy_attr_channel(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"channel">>, <<"destroy">>, __TopXMLNS}}); decode_mix_destroy_attr_channel(__TopXMLNS, _val) -> case catch jid:nodeprep(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"channel">>, <<"destroy">>, __TopXMLNS}}); _res -> _res end. encode_mix_destroy_attr_channel(_val, _acc) -> [{<<"channel">>, _val} | _acc]. decode_mix_create(__TopXMLNS, __Opts, {xmlel, <<"create">>, _attrs, _els}) -> Channel = decode_mix_create_attrs(__TopXMLNS, _attrs, undefined), {mix_create, Channel}. decode_mix_create_attrs(__TopXMLNS, [{<<"channel">>, _val} | _attrs], _Channel) -> decode_mix_create_attrs(__TopXMLNS, _attrs, _val); decode_mix_create_attrs(__TopXMLNS, [_ | _attrs], Channel) -> decode_mix_create_attrs(__TopXMLNS, _attrs, Channel); decode_mix_create_attrs(__TopXMLNS, [], Channel) -> decode_mix_create_attr_channel(__TopXMLNS, Channel). encode_mix_create({mix_create, Channel}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = [], _attrs = encode_mix_create_attr_channel(Channel, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"create">>, _attrs, _els}. decode_mix_create_attr_channel(__TopXMLNS, undefined) -> <<>>; decode_mix_create_attr_channel(__TopXMLNS, _val) -> case catch nodeprep(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"channel">>, <<"create">>, __TopXMLNS}}); _res -> _res end. encode_mix_create_attr_channel(<<>>, _acc) -> _acc; encode_mix_create_attr_channel(_val, _acc) -> [{<<"channel">>, _val} | _acc]. decode_mix_participant(__TopXMLNS, __Opts, {xmlel, <<"participant">>, _attrs, _els}) -> {Jid, Nick} = decode_mix_participant_attrs(__TopXMLNS, _attrs, undefined, undefined), {mix_participant, Jid, Nick}. decode_mix_participant_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Nick) -> decode_mix_participant_attrs(__TopXMLNS, _attrs, _val, Nick); decode_mix_participant_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], Jid, _Nick) -> decode_mix_participant_attrs(__TopXMLNS, _attrs, Jid, _val); decode_mix_participant_attrs(__TopXMLNS, [_ | _attrs], Jid, Nick) -> decode_mix_participant_attrs(__TopXMLNS, _attrs, Jid, Nick); decode_mix_participant_attrs(__TopXMLNS, [], Jid, Nick) -> {decode_mix_participant_attr_jid(__TopXMLNS, Jid), decode_mix_participant_attr_nick(__TopXMLNS, Nick)}. encode_mix_participant({mix_participant, Jid, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = [], _attrs = encode_mix_participant_attr_nick(Nick, encode_mix_participant_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"participant">>, _attrs, _els}. decode_mix_participant_attr_jid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"jid">>, <<"participant">>, __TopXMLNS}}); decode_mix_participant_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"participant">>, __TopXMLNS}}); _res -> _res end. encode_mix_participant_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_mix_participant_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_mix_participant_attr_nick(__TopXMLNS, _val) -> _val. encode_mix_participant_attr_nick(<<>>, _acc) -> _acc; encode_mix_participant_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_mix_leave(__TopXMLNS, __Opts, {xmlel, <<"leave">>, _attrs, _els}) -> {mix_leave}. encode_mix_leave({mix_leave}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"leave">>, _attrs, _els}. decode_mix_join(__TopXMLNS, __Opts, {xmlel, <<"join">>, _attrs, _els}) -> {Subscribe, Nick} = decode_mix_join_els(__TopXMLNS, __Opts, _els, [], <<>>), {Id, Jid} = decode_mix_join_attrs(__TopXMLNS, _attrs, undefined, undefined), {mix_join, Id, Jid, Nick, Subscribe}. decode_mix_join_els(__TopXMLNS, __Opts, [], Subscribe, Nick) -> {lists:reverse(Subscribe), Nick}; decode_mix_join_els(__TopXMLNS, __Opts, [{xmlel, <<"subscribe">>, _attrs, _} = _el | _els], Subscribe, Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_join_els(__TopXMLNS, __Opts, _els, [decode_mix_subscribe(<<"urn:xmpp:mix:core:0">>, __Opts, _el) | Subscribe], Nick); _ -> decode_mix_join_els(__TopXMLNS, __Opts, _els, Subscribe, Nick) end; decode_mix_join_els(__TopXMLNS, __Opts, [{xmlel, <<"nick">>, _attrs, _} = _el | _els], Subscribe, Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_join_els(__TopXMLNS, __Opts, _els, Subscribe, decode_mix_nick(<<"urn:xmpp:mix:core:0">>, __Opts, _el)); _ -> decode_mix_join_els(__TopXMLNS, __Opts, _els, Subscribe, Nick) end; decode_mix_join_els(__TopXMLNS, __Opts, [_ | _els], Subscribe, Nick) -> decode_mix_join_els(__TopXMLNS, __Opts, _els, Subscribe, Nick). decode_mix_join_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, Jid) -> decode_mix_join_attrs(__TopXMLNS, _attrs, _val, Jid); decode_mix_join_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Id, _Jid) -> decode_mix_join_attrs(__TopXMLNS, _attrs, Id, _val); decode_mix_join_attrs(__TopXMLNS, [_ | _attrs], Id, Jid) -> decode_mix_join_attrs(__TopXMLNS, _attrs, Id, Jid); decode_mix_join_attrs(__TopXMLNS, [], Id, Jid) -> {decode_mix_join_attr_id(__TopXMLNS, Id), decode_mix_join_attr_jid(__TopXMLNS, Jid)}. encode_mix_join({mix_join, Id, Jid, Nick, Subscribe}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = lists:reverse('encode_mix_join_$subscribe'(Subscribe, __NewTopXMLNS, 'encode_mix_join_$nick'(Nick, __NewTopXMLNS, []))), _attrs = encode_mix_join_attr_jid(Jid, encode_mix_join_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"join">>, _attrs, _els}. 'encode_mix_join_$subscribe'([], __TopXMLNS, _acc) -> _acc; 'encode_mix_join_$subscribe'([Subscribe | _els], __TopXMLNS, _acc) -> 'encode_mix_join_$subscribe'(_els, __TopXMLNS, [encode_mix_subscribe(Subscribe, __TopXMLNS) | _acc]). 'encode_mix_join_$nick'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_mix_join_$nick'(Nick, __TopXMLNS, _acc) -> [encode_mix_nick(Nick, __TopXMLNS) | _acc]. decode_mix_join_attr_id(__TopXMLNS, undefined) -> <<>>; decode_mix_join_attr_id(__TopXMLNS, _val) -> _val. encode_mix_join_attr_id(<<>>, _acc) -> _acc; encode_mix_join_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_mix_join_attr_jid(__TopXMLNS, undefined) -> undefined; decode_mix_join_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"join">>, __TopXMLNS}}); _res -> _res end. encode_mix_join_attr_jid(undefined, _acc) -> _acc; encode_mix_join_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_mix_setnick(__TopXMLNS, __Opts, {xmlel, <<"setnick">>, _attrs, _els}) -> Nick = decode_mix_setnick_els(__TopXMLNS, __Opts, _els, error), {mix_setnick, Nick}. decode_mix_setnick_els(__TopXMLNS, __Opts, [], Nick) -> case Nick of error -> erlang:error({xmpp_codec, {missing_tag, <<"nick">>, __TopXMLNS}}); {value, Nick1} -> Nick1 end; decode_mix_setnick_els(__TopXMLNS, __Opts, [{xmlel, <<"nick">>, _attrs, _} = _el | _els], Nick) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_setnick_els(__TopXMLNS, __Opts, _els, {value, decode_mix_nick(<<"urn:xmpp:mix:core:0">>, __Opts, _el)}); _ -> decode_mix_setnick_els(__TopXMLNS, __Opts, _els, Nick) end; decode_mix_setnick_els(__TopXMLNS, __Opts, [_ | _els], Nick) -> decode_mix_setnick_els(__TopXMLNS, __Opts, _els, Nick). encode_mix_setnick({mix_setnick, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = lists:reverse('encode_mix_setnick_$nick'(Nick, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"setnick">>, _attrs, _els}. 'encode_mix_setnick_$nick'(Nick, __TopXMLNS, _acc) -> [encode_mix_nick(Nick, __TopXMLNS) | _acc]. decode_mix_submission_id(__TopXMLNS, __Opts, {xmlel, <<"submission-id">>, _attrs, _els}) -> Cdata = decode_mix_submission_id_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mix_submission_id_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mix_submission_id_cdata(__TopXMLNS, Cdata); decode_mix_submission_id_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mix_submission_id_els(__TopXMLNS, __Opts, _els, <>); decode_mix_submission_id_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mix_submission_id_els(__TopXMLNS, __Opts, _els, Cdata). encode_mix_submission_id(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = encode_mix_submission_id_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"submission-id">>, _attrs, _els}. decode_mix_submission_id_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"submission-id">>, __TopXMLNS}}); decode_mix_submission_id_cdata(__TopXMLNS, _val) -> _val. encode_mix_submission_id_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_mix_jid(__TopXMLNS, __Opts, {xmlel, <<"jid">>, _attrs, _els}) -> Cdata = decode_mix_jid_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mix_jid_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mix_jid_cdata(__TopXMLNS, Cdata); decode_mix_jid_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mix_jid_els(__TopXMLNS, __Opts, _els, <>); decode_mix_jid_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mix_jid_els(__TopXMLNS, __Opts, _els, Cdata). encode_mix_jid(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = encode_mix_jid_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"jid">>, _attrs, _els}. decode_mix_jid_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"jid">>, __TopXMLNS}}); decode_mix_jid_cdata(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"jid">>, __TopXMLNS}}); _res -> _res end. encode_mix_jid_cdata(_val, _acc) -> [{xmlcdata, jid:encode(_val)} | _acc]. decode_mix_nick(__TopXMLNS, __Opts, {xmlel, <<"nick">>, _attrs, _els}) -> Cdata = decode_mix_nick_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mix_nick_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mix_nick_cdata(__TopXMLNS, Cdata); decode_mix_nick_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mix_nick_els(__TopXMLNS, __Opts, _els, <>); decode_mix_nick_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mix_nick_els(__TopXMLNS, __Opts, _els, Cdata). encode_mix_nick(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = encode_mix_nick_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"nick">>, _attrs, _els}. decode_mix_nick_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"nick">>, __TopXMLNS}}); decode_mix_nick_cdata(__TopXMLNS, _val) -> _val. encode_mix_nick_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_mix_subscribe(__TopXMLNS, __Opts, {xmlel, <<"subscribe">>, _attrs, _els}) -> Node = decode_mix_subscribe_attrs(__TopXMLNS, _attrs, undefined), Node. decode_mix_subscribe_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_mix_subscribe_attrs(__TopXMLNS, _attrs, _val); decode_mix_subscribe_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_mix_subscribe_attrs(__TopXMLNS, _attrs, Node); decode_mix_subscribe_attrs(__TopXMLNS, [], Node) -> decode_mix_subscribe_attr_node(__TopXMLNS, Node). encode_mix_subscribe(Node, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:core:0">>, [], __TopXMLNS), _els = [], _attrs = encode_mix_subscribe_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"subscribe">>, _attrs, _els}. decode_mix_subscribe_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"subscribe">>, __TopXMLNS}}); decode_mix_subscribe_attr_node(__TopXMLNS, _val) -> _val. encode_mix_subscribe_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. xmpp-1.4.4/src/mam_query.erl0000644000232200023220000002415313610066730016353 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: mam_query.xdata %% Form type: urn:xmpp:mam:1 %% Document: XEP-0313 -module(mam_query). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("mam_query.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [with | start | 'end' | withtext]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"urn:xmpp:mam:1">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {with, Val} -> [encode_with(Val, Lang, lists:member(with, Required))]; {start, Val} -> [encode_start(Val, Lang, lists:member(start, Required))]; {'end', Val} -> [encode_end(Val, Lang, lists:member('end', Required))]; {withtext, Val} -> [encode_withtext(Val, Lang, lists:member(withtext, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"urn:xmpp:mam:1">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"with">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try jid:decode(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"with">>, Required), [{with, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"with">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"with">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"with">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"with">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"with">>, XMLNS}}); do_decode([#xdata_field{var = <<"start">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try xmpp_util:decode_timestamp(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"start">>, Required), [{start, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"start">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"start">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"start">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"start">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"start">>, XMLNS}}); do_decode([#xdata_field{var = <<"end">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try xmpp_util:decode_timestamp(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"end">>, Required), [{'end', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"end">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"end">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"end">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"end">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"end">>, XMLNS}}); do_decode([#xdata_field{var = <<"withtext">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"withtext">>, Required), [{withtext, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"withtext">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"withtext">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"withtext">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"withtext">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"withtext">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_with(jid:jid() | undefined, binary(), boolean()) -> xdata_field(). encode_with(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [jid:encode(Value)] end, Opts = [], #xdata_field{var = <<"with">>, values = Values, required = IsRequired, type = 'jid-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("User JID"))}. -spec encode_start(erlang:timestamp() | undefined, binary(), boolean()) -> xdata_field(). encode_start(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"start">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Search from the date"))}. -spec encode_end(erlang:timestamp() | undefined, binary(), boolean()) -> xdata_field(). encode_end(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"end">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Search until the date"))}. -spec encode_withtext(binary(), binary(), boolean()) -> xdata_field(). encode_withtext(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"withtext">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Search the text"))}. xmpp-1.4.4/src/pubsub_subscribe_options.erl0000644000232200023220000004552113610066730021472 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_subscribe_options.xdata %% Form type: http://jabber.org/protocol/pubsub#subscribe_options %% Document: XEP-0060 -module(pubsub_subscribe_options). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("pubsub_subscribe_options.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [deliver | digest | digest_frequency | expire | include_body | 'show-values' | subscription_type | subscription_depth]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/pubsub#subscribe_o" "ptions">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {deliver, Val} -> [encode_deliver(Val, Lang, lists:member(deliver, Required))]; {digest, Val} -> [encode_digest(Val, Lang, lists:member(digest, Required))]; {digest_frequency, Val} -> [encode_digest_frequency(Val, Lang, lists:member(digest_frequency, Required))]; {expire, Val} -> [encode_expire(Val, Lang, lists:member(expire, Required))]; {include_body, Val} -> [encode_include_body(Val, Lang, lists:member(include_body, Required))]; {'show-values', Val} -> ['encode_show-values'(Val, default, Lang, lists:member('show-values', Required))]; {'show-values', Val, Opts} -> ['encode_show-values'(Val, Opts, Lang, lists:member('show-values', Required))]; {subscription_type, Val} -> [encode_subscription_type(Val, default, Lang, lists:member(subscription_type, Required))]; {subscription_type, Val, Opts} -> [encode_subscription_type(Val, Opts, Lang, lists:member(subscription_type, Required))]; {subscription_depth, Val} -> [encode_subscription_depth(Val, default, Lang, lists:member(subscription_depth, Required))]; {subscription_depth, Val, Opts} -> [encode_subscription_depth(Val, Opts, Lang, lists:member(subscription_depth, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/pubsub#subscribe_o" "ptions">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"pubsub#deliver">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#deliver">>, Required), [{deliver, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#deliver">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#deliver">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#deliver">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#deliver">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#deliver">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#digest">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#digest">>, Required), [{digest, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#digest">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#digest">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#digest">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#digest">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#digest">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#digest_frequency">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#digest_frequency">>, Required), [{digest_frequency, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#digest_frequency">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#digest_frequency">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#digest_frequency">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#digest_frequency">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#digest_frequency">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#expire">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#expire">>, Required), [{expire, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#expire">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#expire">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#expire">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#expire">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#expire">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#include_body">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#include_body">>, Required), [{include_body, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#include_body">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#include_body">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#include_body">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#include_body">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#include_body">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#show-values">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [dec_enum(Value, [away, chat, dnd, online, xa]) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#show-values">>, Required), [{'show-values', Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#show-values">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#subscription_type">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [items, nodes]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#subscription_type">>, Required), [{subscription_type, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#subscription_type">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#subscription_type">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#subscription_type">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#subscription_type">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#subscription_type">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#subscription_depth">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, ['1', all]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#subscription_depth">>, Required), [{subscription_depth, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#subscription_depth">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#subscription_depth">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#subscription_depth">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#subscription_depth">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#subscription_depth">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_deliver(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_deliver(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#deliver">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether an entity wants to receive or " "disable notifications"))}. -spec encode_digest(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_digest(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#digest">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether an entity wants to receive digests " "(aggregations) of notifications or all " "notifications individually"))}. -spec encode_digest_frequency(binary(), binary(), boolean()) -> xdata_field(). encode_digest_frequency(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#digest_frequency">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The minimum number of milliseconds between " "sending any two notification digests"))}. -spec encode_expire(binary(), binary(), boolean()) -> xdata_field(). encode_expire(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#expire">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The DateTime at which a leased subscription " "will end or has ended"))}. -spec encode_include_body(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_include_body(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#include_body">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether an entity wants to receive an " "XMPP message body in addition to the " "payload format"))}. -spec 'encode_show-values'(['show-values'()], default | options('show-values'()), binary(), boolean()) -> xdata_field(). 'encode_show-values'(Value, Options, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [enc_enum(V) || V <- Value] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("XMPP Show Value of Away")), value = <<"away">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("XMPP Show Value of Chat")), value = <<"chat">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("XMPP Show Value of DND (Do Not Disturb)")), value = <<"dnd">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Mere Availability in XMPP (No Show Value)")), value = <<"online">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("XMPP Show Value of XA (Extended Away)")), value = <<"xa">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#show-values">>, values = Values, required = IsRequired, type = 'list-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The presence states for which an entity " "wants to receive notifications"))}. -spec encode_subscription_type(subscription_type() | undefined, default | options(subscription_type()), binary(), boolean()) -> xdata_field(). encode_subscription_type(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Receive notification of new items only")), value = <<"items">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Receive notification of new nodes only")), value = <<"nodes">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#subscription_type">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = <<>>}. -spec encode_subscription_depth(subscription_depth() | undefined, default | options(subscription_depth()), binary(), boolean()) -> xdata_field(). encode_subscription_depth(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Receive notification from direct child " "nodes only")), value = <<"1">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Receive notification from all descendent " "nodes")), value = <<"all">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#subscription_depth">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = <<>>}. xmpp-1.4.4/src/xep0184.erl0000644000232200023220000000547213610066730015470 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0184). -compile(export_all). do_decode(<<"received">>, <<"urn:xmpp:receipts">>, El, Opts) -> decode_receipt_response(<<"urn:xmpp:receipts">>, Opts, El); do_decode(<<"request">>, <<"urn:xmpp:receipts">>, El, Opts) -> decode_receipt_request(<<"urn:xmpp:receipts">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"received">>, <<"urn:xmpp:receipts">>}, {<<"request">>, <<"urn:xmpp:receipts">>}]. do_encode({receipt_request} = Request, TopXMLNS) -> encode_receipt_request(Request, TopXMLNS); do_encode({receipt_response, _} = Received, TopXMLNS) -> encode_receipt_response(Received, TopXMLNS). do_get_name({receipt_request}) -> <<"request">>; do_get_name({receipt_response, _}) -> <<"received">>. do_get_ns({receipt_request}) -> <<"urn:xmpp:receipts">>; do_get_ns({receipt_response, _}) -> <<"urn:xmpp:receipts">>. pp(receipt_request, 0) -> []; pp(receipt_response, 1) -> [id]; pp(_, _) -> no. records() -> [{receipt_request, 0}, {receipt_response, 1}]. decode_receipt_response(__TopXMLNS, __Opts, {xmlel, <<"received">>, _attrs, _els}) -> Id = decode_receipt_response_attrs(__TopXMLNS, _attrs, undefined), {receipt_response, Id}. decode_receipt_response_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id) -> decode_receipt_response_attrs(__TopXMLNS, _attrs, _val); decode_receipt_response_attrs(__TopXMLNS, [_ | _attrs], Id) -> decode_receipt_response_attrs(__TopXMLNS, _attrs, Id); decode_receipt_response_attrs(__TopXMLNS, [], Id) -> decode_receipt_response_attr_id(__TopXMLNS, Id). encode_receipt_response({receipt_response, Id}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:receipts">>, [], __TopXMLNS), _els = [], _attrs = encode_receipt_response_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"received">>, _attrs, _els}. decode_receipt_response_attr_id(__TopXMLNS, undefined) -> <<>>; decode_receipt_response_attr_id(__TopXMLNS, _val) -> _val. encode_receipt_response_attr_id(<<>>, _acc) -> _acc; encode_receipt_response_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_receipt_request(__TopXMLNS, __Opts, {xmlel, <<"request">>, _attrs, _els}) -> {receipt_request}. encode_receipt_request({receipt_request}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:receipts">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"request">>, _attrs, _els}. xmpp-1.4.4/src/xep0045.erl0000644000232200023220000022504713610066730015466 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0045). -compile(export_all). do_decode(<<"unique">>, <<"http://jabber.org/protocol/muc#unique">>, El, Opts) -> decode_muc_unique(<<"http://jabber.org/protocol/muc#unique">>, Opts, El); do_decode(<<"x">>, <<"http://jabber.org/protocol/muc">>, El, Opts) -> decode_muc(<<"http://jabber.org/protocol/muc">>, Opts, El); do_decode(<<"query">>, <<"http://jabber.org/protocol/muc#admin">>, El, Opts) -> decode_muc_admin(<<"http://jabber.org/protocol/muc#admin">>, Opts, El); do_decode(<<"continue">>, <<"http://jabber.org/protocol/muc#admin">>, El, Opts) -> decode_muc_admin_continue(<<"http://jabber.org/protocol/muc#admin">>, Opts, El); do_decode(<<"actor">>, <<"http://jabber.org/protocol/muc#admin">>, El, Opts) -> decode_muc_admin_actor(<<"http://jabber.org/protocol/muc#admin">>, Opts, El); do_decode(<<"item">>, <<"http://jabber.org/protocol/muc#admin">>, El, Opts) -> decode_muc_admin_item(<<"http://jabber.org/protocol/muc#admin">>, Opts, El); do_decode(<<"item">>, <<"http://jabber.org/protocol/muc#owner">>, El, Opts) -> decode_muc_owner_item(<<"http://jabber.org/protocol/muc#owner">>, Opts, El); do_decode(<<"query">>, <<"http://jabber.org/protocol/muc#owner">>, El, Opts) -> decode_muc_owner(<<"http://jabber.org/protocol/muc#owner">>, Opts, El); do_decode(<<"password">>, <<"http://jabber.org/protocol/muc#owner">>, El, Opts) -> decode_muc_password(<<"http://jabber.org/protocol/muc#owner">>, Opts, El); do_decode(<<"password">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_password(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"password">>, <<"http://jabber.org/protocol/muc">>, El, Opts) -> decode_muc_password(<<"http://jabber.org/protocol/muc">>, Opts, El); do_decode(<<"x">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_user(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"item">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_user_item(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"status">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_user_status(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"continue">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_user_continue(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"actor">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_user_actor(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"invite">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_user_invite(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"destroy">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_destroy(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"destroy">>, <<"http://jabber.org/protocol/muc#owner">>, El, Opts) -> decode_muc_destroy(<<"http://jabber.org/protocol/muc#owner">>, Opts, El); do_decode(<<"decline">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_user_decline(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"reason">>, <<"http://jabber.org/protocol/muc#user">>, El, Opts) -> decode_muc_reason(<<"http://jabber.org/protocol/muc#user">>, Opts, El); do_decode(<<"reason">>, <<"http://jabber.org/protocol/muc#admin">>, El, Opts) -> decode_muc_reason(<<"http://jabber.org/protocol/muc#admin">>, Opts, El); do_decode(<<"reason">>, <<"http://jabber.org/protocol/muc#owner">>, El, Opts) -> decode_muc_reason(<<"http://jabber.org/protocol/muc#owner">>, Opts, El); do_decode(<<"history">>, <<"http://jabber.org/protocol/muc">>, El, Opts) -> decode_muc_history(<<"http://jabber.org/protocol/muc">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"unique">>, <<"http://jabber.org/protocol/muc#unique">>}, {<<"x">>, <<"http://jabber.org/protocol/muc">>}, {<<"query">>, <<"http://jabber.org/protocol/muc#admin">>}, {<<"continue">>, <<"http://jabber.org/protocol/muc#admin">>}, {<<"actor">>, <<"http://jabber.org/protocol/muc#admin">>}, {<<"item">>, <<"http://jabber.org/protocol/muc#admin">>}, {<<"item">>, <<"http://jabber.org/protocol/muc#owner">>}, {<<"query">>, <<"http://jabber.org/protocol/muc#owner">>}, {<<"password">>, <<"http://jabber.org/protocol/muc#owner">>}, {<<"password">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"password">>, <<"http://jabber.org/protocol/muc">>}, {<<"x">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"item">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"status">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"continue">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"actor">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"invite">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"destroy">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"destroy">>, <<"http://jabber.org/protocol/muc#owner">>}, {<<"decline">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"reason">>, <<"http://jabber.org/protocol/muc#user">>}, {<<"reason">>, <<"http://jabber.org/protocol/muc#admin">>}, {<<"reason">>, <<"http://jabber.org/protocol/muc#owner">>}, {<<"history">>, <<"http://jabber.org/protocol/muc">>}]. do_encode({muc_history, _, _, _, _} = History, TopXMLNS) -> encode_muc_history(History, TopXMLNS); do_encode({muc_decline, _, _, _} = Decline, TopXMLNS) -> encode_muc_user_decline(Decline, TopXMLNS); do_encode({muc_destroy, _, _, _, _} = Destroy, TopXMLNS) -> encode_muc_destroy(Destroy, TopXMLNS); do_encode({muc_invite, _, _, _, _} = Invite, TopXMLNS) -> encode_muc_user_invite(Invite, TopXMLNS); do_encode({muc_user, _, _, _, _, _, _} = X, TopXMLNS) -> encode_muc_user(X, TopXMLNS); do_encode({muc_owner, _, _, _} = Query, TopXMLNS) -> encode_muc_owner(Query, TopXMLNS); do_encode({muc_item, _, _, _, _, _, _, _} = Item, TopXMLNS) -> encode_muc_admin_item(Item, TopXMLNS); do_encode({muc_actor, _, _} = Actor, TopXMLNS) -> encode_muc_admin_actor(Actor, TopXMLNS); do_encode({muc_admin, _} = Query, TopXMLNS) -> encode_muc_admin(Query, TopXMLNS); do_encode({muc, _, _} = X, TopXMLNS) -> encode_muc(X, TopXMLNS); do_encode({muc_unique, _} = Unique, TopXMLNS) -> encode_muc_unique(Unique, TopXMLNS). do_get_name({muc, _, _}) -> <<"x">>; do_get_name({muc_actor, _, _}) -> <<"actor">>; do_get_name({muc_admin, _}) -> <<"query">>; do_get_name({muc_decline, _, _, _}) -> <<"decline">>; do_get_name({muc_destroy, _, _, _, _}) -> <<"destroy">>; do_get_name({muc_history, _, _, _, _}) -> <<"history">>; do_get_name({muc_invite, _, _, _, _}) -> <<"invite">>; do_get_name({muc_item, _, _, _, _, _, _, _}) -> <<"item">>; do_get_name({muc_owner, _, _, _}) -> <<"query">>; do_get_name({muc_unique, _}) -> <<"unique">>; do_get_name({muc_user, _, _, _, _, _, _}) -> <<"x">>. do_get_ns({muc, _, _}) -> <<"http://jabber.org/protocol/muc">>; do_get_ns({muc_admin, _}) -> <<"http://jabber.org/protocol/muc#admin">>; do_get_ns({muc_decline, _, _, _}) -> <<"http://jabber.org/protocol/muc#user">>; do_get_ns({muc_destroy, Xmlns, _, _, _}) -> Xmlns; do_get_ns({muc_history, _, _, _, _}) -> <<"http://jabber.org/protocol/muc">>; do_get_ns({muc_invite, _, _, _, _}) -> <<"http://jabber.org/protocol/muc#user">>; do_get_ns({muc_owner, _, _, _}) -> <<"http://jabber.org/protocol/muc#owner">>; do_get_ns({muc_unique, _}) -> <<"http://jabber.org/protocol/muc#unique">>; do_get_ns({muc_user, _, _, _, _, _, _}) -> <<"http://jabber.org/protocol/muc#user">>. pp(muc_history, 4) -> [maxchars, maxstanzas, seconds, since]; pp(muc_decline, 3) -> [reason, from, to]; pp(muc_destroy, 4) -> [xmlns, jid, reason, password]; pp(muc_invite, 4) -> [reason, from, to, continue]; pp(muc_user, 6) -> [decline, destroy, invites, items, status_codes, password]; pp(muc_owner, 3) -> [destroy, config, items]; pp(muc_item, 7) -> [actor, continue, reason, affiliation, role, jid, nick]; pp(muc_actor, 2) -> [jid, nick]; pp(muc_admin, 1) -> [items]; pp(muc, 2) -> [history, password]; pp(muc_unique, 1) -> [name]; pp(_, _) -> no. records() -> [{muc_history, 4}, {muc_decline, 3}, {muc_destroy, 4}, {muc_invite, 4}, {muc_user, 6}, {muc_owner, 3}, {muc_item, 7}, {muc_actor, 2}, {muc_admin, 1}, {muc, 2}, {muc_unique, 1}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_muc_unique(__TopXMLNS, __Opts, {xmlel, <<"unique">>, _attrs, _els}) -> Name = decode_muc_unique_els(__TopXMLNS, __Opts, _els, <<>>), {muc_unique, Name}. decode_muc_unique_els(__TopXMLNS, __Opts, [], Name) -> decode_muc_unique_cdata(__TopXMLNS, Name); decode_muc_unique_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Name) -> decode_muc_unique_els(__TopXMLNS, __Opts, _els, <>); decode_muc_unique_els(__TopXMLNS, __Opts, [_ | _els], Name) -> decode_muc_unique_els(__TopXMLNS, __Opts, _els, Name). encode_muc_unique({muc_unique, Name}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#unique">>, [], __TopXMLNS), _els = encode_muc_unique_cdata(Name, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unique">>, _attrs, _els}. decode_muc_unique_cdata(__TopXMLNS, <<>>) -> <<>>; decode_muc_unique_cdata(__TopXMLNS, _val) -> _val. encode_muc_unique_cdata(<<>>, _acc) -> _acc; encode_muc_unique_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_muc(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> {Password, History} = decode_muc_els(__TopXMLNS, __Opts, _els, undefined, undefined), {muc, History, Password}. decode_muc_els(__TopXMLNS, __Opts, [], Password, History) -> {Password, History}; decode_muc_els(__TopXMLNS, __Opts, [{xmlel, <<"history">>, _attrs, _} = _el | _els], Password, History) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc">> -> decode_muc_els(__TopXMLNS, __Opts, _els, Password, decode_muc_history(<<"http://jabber.org/protocol/muc">>, __Opts, _el)); _ -> decode_muc_els(__TopXMLNS, __Opts, _els, Password, History) end; decode_muc_els(__TopXMLNS, __Opts, [{xmlel, <<"password">>, _attrs, _} = _el | _els], Password, History) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_els(__TopXMLNS, __Opts, _els, decode_muc_password(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el), History); <<"http://jabber.org/protocol/muc#user">> -> decode_muc_els(__TopXMLNS, __Opts, _els, decode_muc_password(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el), History); <<"http://jabber.org/protocol/muc">> -> decode_muc_els(__TopXMLNS, __Opts, _els, decode_muc_password(<<"http://jabber.org/protocol/muc">>, __Opts, _el), History); _ -> decode_muc_els(__TopXMLNS, __Opts, _els, Password, History) end; decode_muc_els(__TopXMLNS, __Opts, [_ | _els], Password, History) -> decode_muc_els(__TopXMLNS, __Opts, _els, Password, History). encode_muc({muc, History, Password}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_$password'(Password, __NewTopXMLNS, 'encode_muc_$history'(History, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x">>, _attrs, _els}. 'encode_muc_$password'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_$password'(Password, __TopXMLNS, _acc) -> [encode_muc_password(Password, __TopXMLNS) | _acc]. 'encode_muc_$history'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_$history'(History, __TopXMLNS, _acc) -> [encode_muc_history(History, __TopXMLNS) | _acc]. decode_muc_admin(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> Items = decode_muc_admin_els(__TopXMLNS, __Opts, _els, []), {muc_admin, Items}. decode_muc_admin_els(__TopXMLNS, __Opts, [], Items) -> lists:reverse(Items); decode_muc_admin_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_admin_els(__TopXMLNS, __Opts, _els, [decode_muc_admin_item(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el) | Items]); _ -> decode_muc_admin_els(__TopXMLNS, __Opts, _els, Items) end; decode_muc_admin_els(__TopXMLNS, __Opts, [_ | _els], Items) -> decode_muc_admin_els(__TopXMLNS, __Opts, _els, Items). encode_muc_admin({muc_admin, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#admin">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_admin_$items'(Items, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. 'encode_muc_admin_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_admin_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_muc_admin_$items'(_els, __TopXMLNS, [encode_muc_admin_item(Items, __TopXMLNS) | _acc]). decode_muc_admin_continue(__TopXMLNS, __Opts, {xmlel, <<"continue">>, _attrs, _els}) -> Thread = decode_muc_admin_continue_attrs(__TopXMLNS, _attrs, undefined), Thread. decode_muc_admin_continue_attrs(__TopXMLNS, [{<<"thread">>, _val} | _attrs], _Thread) -> decode_muc_admin_continue_attrs(__TopXMLNS, _attrs, _val); decode_muc_admin_continue_attrs(__TopXMLNS, [_ | _attrs], Thread) -> decode_muc_admin_continue_attrs(__TopXMLNS, _attrs, Thread); decode_muc_admin_continue_attrs(__TopXMLNS, [], Thread) -> decode_muc_admin_continue_attr_thread(__TopXMLNS, Thread). encode_muc_admin_continue(Thread, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#admin">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_admin_continue_attr_thread(Thread, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"continue">>, _attrs, _els}. decode_muc_admin_continue_attr_thread(__TopXMLNS, undefined) -> <<>>; decode_muc_admin_continue_attr_thread(__TopXMLNS, _val) -> _val. encode_muc_admin_continue_attr_thread(<<>>, _acc) -> _acc; encode_muc_admin_continue_attr_thread(_val, _acc) -> [{<<"thread">>, _val} | _acc]. decode_muc_admin_actor(__TopXMLNS, __Opts, {xmlel, <<"actor">>, _attrs, _els}) -> {Jid, Nick} = decode_muc_admin_actor_attrs(__TopXMLNS, _attrs, undefined, undefined), {muc_actor, Jid, Nick}. decode_muc_admin_actor_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Nick) -> decode_muc_admin_actor_attrs(__TopXMLNS, _attrs, _val, Nick); decode_muc_admin_actor_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], Jid, _Nick) -> decode_muc_admin_actor_attrs(__TopXMLNS, _attrs, Jid, _val); decode_muc_admin_actor_attrs(__TopXMLNS, [_ | _attrs], Jid, Nick) -> decode_muc_admin_actor_attrs(__TopXMLNS, _attrs, Jid, Nick); decode_muc_admin_actor_attrs(__TopXMLNS, [], Jid, Nick) -> {decode_muc_admin_actor_attr_jid(__TopXMLNS, Jid), decode_muc_admin_actor_attr_nick(__TopXMLNS, Nick)}. encode_muc_admin_actor({muc_actor, Jid, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#admin">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_admin_actor_attr_nick(Nick, encode_muc_admin_actor_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"actor">>, _attrs, _els}. decode_muc_admin_actor_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_admin_actor_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"actor">>, __TopXMLNS}}); _res -> _res end. encode_muc_admin_actor_attr_jid(undefined, _acc) -> _acc; encode_muc_admin_actor_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_admin_actor_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_muc_admin_actor_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_admin_actor_attr_nick(<<>>, _acc) -> _acc; encode_muc_admin_actor_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_muc_admin_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> {Actor, Continue, Reason} = decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, undefined, undefined, <<>>), {Affiliation, Role, Jid, Nick} = decode_muc_admin_item_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {muc_item, Actor, Continue, Reason, Affiliation, Role, Jid, Nick}. decode_muc_admin_item_els(__TopXMLNS, __Opts, [], Actor, Continue, Reason) -> {Actor, Continue, Reason}; decode_muc_admin_item_els(__TopXMLNS, __Opts, [{xmlel, <<"actor">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, decode_muc_admin_actor(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el), Continue, Reason); _ -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_admin_item_els(__TopXMLNS, __Opts, [{xmlel, <<"continue">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, decode_muc_admin_continue(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el), Reason); _ -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_admin_item_els(__TopXMLNS, __Opts, [{xmlel, <<"reason">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_admin_item_els(__TopXMLNS, __Opts, [_ | _els], Actor, Continue, Reason) -> decode_muc_admin_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason). decode_muc_admin_item_attrs(__TopXMLNS, [{<<"affiliation">>, _val} | _attrs], _Affiliation, Role, Jid, Nick) -> decode_muc_admin_item_attrs(__TopXMLNS, _attrs, _val, Role, Jid, Nick); decode_muc_admin_item_attrs(__TopXMLNS, [{<<"role">>, _val} | _attrs], Affiliation, _Role, Jid, Nick) -> decode_muc_admin_item_attrs(__TopXMLNS, _attrs, Affiliation, _val, Jid, Nick); decode_muc_admin_item_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Affiliation, Role, _Jid, Nick) -> decode_muc_admin_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, _val, Nick); decode_muc_admin_item_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], Affiliation, Role, Jid, _Nick) -> decode_muc_admin_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, Jid, _val); decode_muc_admin_item_attrs(__TopXMLNS, [_ | _attrs], Affiliation, Role, Jid, Nick) -> decode_muc_admin_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, Jid, Nick); decode_muc_admin_item_attrs(__TopXMLNS, [], Affiliation, Role, Jid, Nick) -> {decode_muc_admin_item_attr_affiliation(__TopXMLNS, Affiliation), decode_muc_admin_item_attr_role(__TopXMLNS, Role), decode_muc_admin_item_attr_jid(__TopXMLNS, Jid), decode_muc_admin_item_attr_nick(__TopXMLNS, Nick)}. encode_muc_admin_item({muc_item, Actor, Continue, Reason, Affiliation, Role, Jid, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#admin">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_admin_item_$actor'(Actor, __NewTopXMLNS, 'encode_muc_admin_item_$continue'(Continue, __NewTopXMLNS, 'encode_muc_admin_item_$reason'(Reason, __NewTopXMLNS, [])))), _attrs = encode_muc_admin_item_attr_nick(Nick, encode_muc_admin_item_attr_jid(Jid, encode_muc_admin_item_attr_role(Role, encode_muc_admin_item_attr_affiliation(Affiliation, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"item">>, _attrs, _els}. 'encode_muc_admin_item_$actor'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_admin_item_$actor'(Actor, __TopXMLNS, _acc) -> [encode_muc_admin_actor(Actor, __TopXMLNS) | _acc]. 'encode_muc_admin_item_$continue'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_admin_item_$continue'(Continue, __TopXMLNS, _acc) -> [encode_muc_admin_continue(Continue, __TopXMLNS) | _acc]. 'encode_muc_admin_item_$reason'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_muc_admin_item_$reason'(Reason, __TopXMLNS, _acc) -> [encode_muc_reason(Reason, __TopXMLNS) | _acc]. decode_muc_admin_item_attr_affiliation(__TopXMLNS, undefined) -> undefined; decode_muc_admin_item_attr_affiliation(__TopXMLNS, _val) -> case catch dec_enum(_val, [admin, member, none, outcast, owner]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"affiliation">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_admin_item_attr_affiliation(undefined, _acc) -> _acc; encode_muc_admin_item_attr_affiliation(_val, _acc) -> [{<<"affiliation">>, enc_enum(_val)} | _acc]. decode_muc_admin_item_attr_role(__TopXMLNS, undefined) -> undefined; decode_muc_admin_item_attr_role(__TopXMLNS, _val) -> case catch dec_enum(_val, [moderator, none, participant, visitor]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"role">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_admin_item_attr_role(undefined, _acc) -> _acc; encode_muc_admin_item_attr_role(_val, _acc) -> [{<<"role">>, enc_enum(_val)} | _acc]. decode_muc_admin_item_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_admin_item_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_admin_item_attr_jid(undefined, _acc) -> _acc; encode_muc_admin_item_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_admin_item_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_muc_admin_item_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_admin_item_attr_nick(<<>>, _acc) -> _acc; encode_muc_admin_item_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_muc_owner_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> {Actor, Continue, Reason} = decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, undefined, undefined, <<>>), {Affiliation, Role, Jid, Nick} = decode_muc_owner_item_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {muc_item, Actor, Continue, Reason, Affiliation, Role, Jid, Nick}. decode_muc_owner_item_els(__TopXMLNS, __Opts, [], Actor, Continue, Reason) -> {Actor, Continue, Reason}; decode_muc_owner_item_els(__TopXMLNS, __Opts, [{xmlel, <<"actor">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, decode_muc_admin_actor(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el), Continue, Reason); _ -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_owner_item_els(__TopXMLNS, __Opts, [{xmlel, <<"continue">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, decode_muc_admin_continue(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el), Reason); _ -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_owner_item_els(__TopXMLNS, __Opts, [{xmlel, <<"reason">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_owner_item_els(__TopXMLNS, __Opts, [_ | _els], Actor, Continue, Reason) -> decode_muc_owner_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason). decode_muc_owner_item_attrs(__TopXMLNS, [{<<"affiliation">>, _val} | _attrs], _Affiliation, Role, Jid, Nick) -> decode_muc_owner_item_attrs(__TopXMLNS, _attrs, _val, Role, Jid, Nick); decode_muc_owner_item_attrs(__TopXMLNS, [{<<"role">>, _val} | _attrs], Affiliation, _Role, Jid, Nick) -> decode_muc_owner_item_attrs(__TopXMLNS, _attrs, Affiliation, _val, Jid, Nick); decode_muc_owner_item_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Affiliation, Role, _Jid, Nick) -> decode_muc_owner_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, _val, Nick); decode_muc_owner_item_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], Affiliation, Role, Jid, _Nick) -> decode_muc_owner_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, Jid, _val); decode_muc_owner_item_attrs(__TopXMLNS, [_ | _attrs], Affiliation, Role, Jid, Nick) -> decode_muc_owner_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, Jid, Nick); decode_muc_owner_item_attrs(__TopXMLNS, [], Affiliation, Role, Jid, Nick) -> {decode_muc_owner_item_attr_affiliation(__TopXMLNS, Affiliation), decode_muc_owner_item_attr_role(__TopXMLNS, Role), decode_muc_owner_item_attr_jid(__TopXMLNS, Jid), decode_muc_owner_item_attr_nick(__TopXMLNS, Nick)}. encode_muc_owner_item({muc_item, Actor, Continue, Reason, Affiliation, Role, Jid, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#owner">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_owner_item_$actor'(Actor, __NewTopXMLNS, 'encode_muc_owner_item_$continue'(Continue, __NewTopXMLNS, 'encode_muc_owner_item_$reason'(Reason, __NewTopXMLNS, [])))), _attrs = encode_muc_owner_item_attr_nick(Nick, encode_muc_owner_item_attr_jid(Jid, encode_muc_owner_item_attr_role(Role, encode_muc_owner_item_attr_affiliation(Affiliation, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"item">>, _attrs, _els}. 'encode_muc_owner_item_$actor'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_owner_item_$actor'(Actor, __TopXMLNS, _acc) -> [encode_muc_admin_actor(Actor, __TopXMLNS) | _acc]. 'encode_muc_owner_item_$continue'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_owner_item_$continue'(Continue, __TopXMLNS, _acc) -> [encode_muc_admin_continue(Continue, __TopXMLNS) | _acc]. 'encode_muc_owner_item_$reason'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_muc_owner_item_$reason'(Reason, __TopXMLNS, _acc) -> [encode_muc_reason(Reason, __TopXMLNS) | _acc]. decode_muc_owner_item_attr_affiliation(__TopXMLNS, undefined) -> undefined; decode_muc_owner_item_attr_affiliation(__TopXMLNS, _val) -> case catch dec_enum(_val, [admin, member, none, outcast, owner]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"affiliation">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_owner_item_attr_affiliation(undefined, _acc) -> _acc; encode_muc_owner_item_attr_affiliation(_val, _acc) -> [{<<"affiliation">>, enc_enum(_val)} | _acc]. decode_muc_owner_item_attr_role(__TopXMLNS, undefined) -> undefined; decode_muc_owner_item_attr_role(__TopXMLNS, _val) -> case catch dec_enum(_val, [moderator, none, participant, visitor]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"role">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_owner_item_attr_role(undefined, _acc) -> _acc; encode_muc_owner_item_attr_role(_val, _acc) -> [{<<"role">>, enc_enum(_val)} | _acc]. decode_muc_owner_item_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_owner_item_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_owner_item_attr_jid(undefined, _acc) -> _acc; encode_muc_owner_item_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_owner_item_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_muc_owner_item_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_owner_item_attr_nick(<<>>, _acc) -> _acc; encode_muc_owner_item_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_muc_owner(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Items, Config, Destroy} = decode_muc_owner_els(__TopXMLNS, __Opts, _els, [], undefined, undefined), {muc_owner, Destroy, Config, Items}. decode_muc_owner_els(__TopXMLNS, __Opts, [], Items, Config, Destroy) -> {lists:reverse(Items), Config, Destroy}; decode_muc_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"destroy">>, _attrs, _} = _el | _els], Items, Config, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, Items, Config, decode_muc_destroy(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, Items, Config, decode_muc_destroy(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, Items, Config, Destroy) end; decode_muc_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Items, Config, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, Items, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el), Destroy); _ -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, Items, Config, Destroy) end; decode_muc_owner_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items, Config, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, [decode_muc_owner_item(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el) | Items], Config, Destroy); _ -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, Items, Config, Destroy) end; decode_muc_owner_els(__TopXMLNS, __Opts, [_ | _els], Items, Config, Destroy) -> decode_muc_owner_els(__TopXMLNS, __Opts, _els, Items, Config, Destroy). encode_muc_owner({muc_owner, Destroy, Config, Items}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#owner">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_owner_$items'(Items, __NewTopXMLNS, 'encode_muc_owner_$config'(Config, __NewTopXMLNS, 'encode_muc_owner_$destroy'(Destroy, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. 'encode_muc_owner_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_owner_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_muc_owner_$items'(_els, __TopXMLNS, [encode_muc_owner_item(Items, __TopXMLNS) | _acc]). 'encode_muc_owner_$config'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_owner_$config'(Config, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Config, __TopXMLNS) | _acc]. 'encode_muc_owner_$destroy'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_owner_$destroy'(Destroy, __TopXMLNS, _acc) -> [encode_muc_destroy(Destroy, __TopXMLNS) | _acc]. decode_muc_password(__TopXMLNS, __Opts, {xmlel, <<"password">>, _attrs, _els}) -> Cdata = decode_muc_password_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_muc_password_els(__TopXMLNS, __Opts, [], Cdata) -> decode_muc_password_cdata(__TopXMLNS, Cdata); decode_muc_password_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_muc_password_els(__TopXMLNS, __Opts, _els, <>); decode_muc_password_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_muc_password_els(__TopXMLNS, __Opts, _els, Cdata). encode_muc_password(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/muc#owner">>, <<"http://jabber.org/protocol/muc#user">>, <<"http://jabber.org/protocol/muc">>], __TopXMLNS), _els = encode_muc_password_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"password">>, _attrs, _els}. decode_muc_password_cdata(__TopXMLNS, <<>>) -> <<>>; decode_muc_password_cdata(__TopXMLNS, _val) -> _val. encode_muc_password_cdata(<<>>, _acc) -> _acc; encode_muc_password_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_muc_user(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> {Status_codes, Items, Invites, Password, Decline, Destroy} = decode_muc_user_els(__TopXMLNS, __Opts, _els, [], [], [], undefined, undefined, undefined), {muc_user, Decline, Destroy, Invites, Items, Status_codes, Password}. decode_muc_user_els(__TopXMLNS, __Opts, [], Status_codes, Items, Invites, Password, Decline, Destroy) -> {lists:reverse(Status_codes), lists:reverse(Items), lists:reverse(Invites), Password, Decline, Destroy}; decode_muc_user_els(__TopXMLNS, __Opts, [{xmlel, <<"decline">>, _attrs, _} = _el | _els], Status_codes, Items, Invites, Password, Decline, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, decode_muc_user_decline(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el), Destroy); _ -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, Destroy) end; decode_muc_user_els(__TopXMLNS, __Opts, [{xmlel, <<"destroy">>, _attrs, _} = _el | _els], Status_codes, Items, Invites, Password, Decline, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, decode_muc_destroy(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, decode_muc_destroy(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, Destroy) end; decode_muc_user_els(__TopXMLNS, __Opts, [{xmlel, <<"password">>, _attrs, _} = _el | _els], Status_codes, Items, Invites, Password, Decline, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, decode_muc_password(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el), Decline, Destroy); <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, decode_muc_password(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el), Decline, Destroy); <<"http://jabber.org/protocol/muc">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, decode_muc_password(<<"http://jabber.org/protocol/muc">>, __Opts, _el), Decline, Destroy); _ -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, Destroy) end; decode_muc_user_els(__TopXMLNS, __Opts, [{xmlel, <<"invite">>, _attrs, _} = _el | _els], Status_codes, Items, Invites, Password, Decline, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, [decode_muc_user_invite(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el) | Invites], Password, Decline, Destroy); _ -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, Destroy) end; decode_muc_user_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Status_codes, Items, Invites, Password, Decline, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, [decode_muc_user_item(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el) | Items], Invites, Password, Decline, Destroy); _ -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, Destroy) end; decode_muc_user_els(__TopXMLNS, __Opts, [{xmlel, <<"status">>, _attrs, _} = _el | _els], Status_codes, Items, Invites, Password, Decline, Destroy) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_els(__TopXMLNS, __Opts, _els, case decode_muc_user_status(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el) of undefined -> Status_codes; _new_el -> [_new_el | Status_codes] end, Items, Invites, Password, Decline, Destroy); _ -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, Destroy) end; decode_muc_user_els(__TopXMLNS, __Opts, [_ | _els], Status_codes, Items, Invites, Password, Decline, Destroy) -> decode_muc_user_els(__TopXMLNS, __Opts, _els, Status_codes, Items, Invites, Password, Decline, Destroy). encode_muc_user({muc_user, Decline, Destroy, Invites, Items, Status_codes, Password}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#user">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_user_$status_codes'(Status_codes, __NewTopXMLNS, 'encode_muc_user_$items'(Items, __NewTopXMLNS, 'encode_muc_user_$invites'(Invites, __NewTopXMLNS, 'encode_muc_user_$password'(Password, __NewTopXMLNS, 'encode_muc_user_$decline'(Decline, __NewTopXMLNS, 'encode_muc_user_$destroy'(Destroy, __NewTopXMLNS, []))))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x">>, _attrs, _els}. 'encode_muc_user_$status_codes'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_user_$status_codes'([Status_codes | _els], __TopXMLNS, _acc) -> 'encode_muc_user_$status_codes'(_els, __TopXMLNS, [encode_muc_user_status(Status_codes, __TopXMLNS) | _acc]). 'encode_muc_user_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_user_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_muc_user_$items'(_els, __TopXMLNS, [encode_muc_user_item(Items, __TopXMLNS) | _acc]). 'encode_muc_user_$invites'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_user_$invites'([Invites | _els], __TopXMLNS, _acc) -> 'encode_muc_user_$invites'(_els, __TopXMLNS, [encode_muc_user_invite(Invites, __TopXMLNS) | _acc]). 'encode_muc_user_$password'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_$password'(Password, __TopXMLNS, _acc) -> [encode_muc_password(Password, __TopXMLNS) | _acc]. 'encode_muc_user_$decline'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_$decline'(Decline, __TopXMLNS, _acc) -> [encode_muc_user_decline(Decline, __TopXMLNS) | _acc]. 'encode_muc_user_$destroy'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_$destroy'(Destroy, __TopXMLNS, _acc) -> [encode_muc_destroy(Destroy, __TopXMLNS) | _acc]. decode_muc_user_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> {Actor, Continue, Reason} = decode_muc_user_item_els(__TopXMLNS, __Opts, _els, undefined, undefined, <<>>), {Affiliation, Role, Jid, Nick} = decode_muc_user_item_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {muc_item, Actor, Continue, Reason, Affiliation, Role, Jid, Nick}. decode_muc_user_item_els(__TopXMLNS, __Opts, [], Actor, Continue, Reason) -> {Actor, Continue, Reason}; decode_muc_user_item_els(__TopXMLNS, __Opts, [{xmlel, <<"actor">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, decode_muc_user_actor(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el), Continue, Reason); _ -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_user_item_els(__TopXMLNS, __Opts, [{xmlel, <<"continue">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, decode_muc_user_continue(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el), Reason); _ -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_user_item_els(__TopXMLNS, __Opts, [{xmlel, <<"reason">>, _attrs, _} = _el | _els], Actor, Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason) end; decode_muc_user_item_els(__TopXMLNS, __Opts, [_ | _els], Actor, Continue, Reason) -> decode_muc_user_item_els(__TopXMLNS, __Opts, _els, Actor, Continue, Reason). decode_muc_user_item_attrs(__TopXMLNS, [{<<"affiliation">>, _val} | _attrs], _Affiliation, Role, Jid, Nick) -> decode_muc_user_item_attrs(__TopXMLNS, _attrs, _val, Role, Jid, Nick); decode_muc_user_item_attrs(__TopXMLNS, [{<<"role">>, _val} | _attrs], Affiliation, _Role, Jid, Nick) -> decode_muc_user_item_attrs(__TopXMLNS, _attrs, Affiliation, _val, Jid, Nick); decode_muc_user_item_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Affiliation, Role, _Jid, Nick) -> decode_muc_user_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, _val, Nick); decode_muc_user_item_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], Affiliation, Role, Jid, _Nick) -> decode_muc_user_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, Jid, _val); decode_muc_user_item_attrs(__TopXMLNS, [_ | _attrs], Affiliation, Role, Jid, Nick) -> decode_muc_user_item_attrs(__TopXMLNS, _attrs, Affiliation, Role, Jid, Nick); decode_muc_user_item_attrs(__TopXMLNS, [], Affiliation, Role, Jid, Nick) -> {decode_muc_user_item_attr_affiliation(__TopXMLNS, Affiliation), decode_muc_user_item_attr_role(__TopXMLNS, Role), decode_muc_user_item_attr_jid(__TopXMLNS, Jid), decode_muc_user_item_attr_nick(__TopXMLNS, Nick)}. encode_muc_user_item({muc_item, Actor, Continue, Reason, Affiliation, Role, Jid, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#user">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_user_item_$actor'(Actor, __NewTopXMLNS, 'encode_muc_user_item_$continue'(Continue, __NewTopXMLNS, 'encode_muc_user_item_$reason'(Reason, __NewTopXMLNS, [])))), _attrs = encode_muc_user_item_attr_nick(Nick, encode_muc_user_item_attr_jid(Jid, encode_muc_user_item_attr_role(Role, encode_muc_user_item_attr_affiliation(Affiliation, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"item">>, _attrs, _els}. 'encode_muc_user_item_$actor'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_item_$actor'(Actor, __TopXMLNS, _acc) -> [encode_muc_user_actor(Actor, __TopXMLNS) | _acc]. 'encode_muc_user_item_$continue'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_item_$continue'(Continue, __TopXMLNS, _acc) -> [encode_muc_user_continue(Continue, __TopXMLNS) | _acc]. 'encode_muc_user_item_$reason'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_item_$reason'(Reason, __TopXMLNS, _acc) -> [encode_muc_reason(Reason, __TopXMLNS) | _acc]. decode_muc_user_item_attr_affiliation(__TopXMLNS, undefined) -> undefined; decode_muc_user_item_attr_affiliation(__TopXMLNS, _val) -> case catch dec_enum(_val, [admin, member, none, outcast, owner]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"affiliation">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_item_attr_affiliation(undefined, _acc) -> _acc; encode_muc_user_item_attr_affiliation(_val, _acc) -> [{<<"affiliation">>, enc_enum(_val)} | _acc]. decode_muc_user_item_attr_role(__TopXMLNS, undefined) -> undefined; decode_muc_user_item_attr_role(__TopXMLNS, _val) -> case catch dec_enum(_val, [moderator, none, participant, visitor]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"role">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_item_attr_role(undefined, _acc) -> _acc; encode_muc_user_item_attr_role(_val, _acc) -> [{<<"role">>, enc_enum(_val)} | _acc]. decode_muc_user_item_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_user_item_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_item_attr_jid(undefined, _acc) -> _acc; encode_muc_user_item_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_user_item_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_muc_user_item_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_user_item_attr_nick(<<>>, _acc) -> _acc; encode_muc_user_item_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_muc_user_status(__TopXMLNS, __Opts, {xmlel, <<"status">>, _attrs, _els}) -> Code = decode_muc_user_status_attrs(__TopXMLNS, _attrs, undefined), Code. decode_muc_user_status_attrs(__TopXMLNS, [{<<"code">>, _val} | _attrs], _Code) -> decode_muc_user_status_attrs(__TopXMLNS, _attrs, _val); decode_muc_user_status_attrs(__TopXMLNS, [_ | _attrs], Code) -> decode_muc_user_status_attrs(__TopXMLNS, _attrs, Code); decode_muc_user_status_attrs(__TopXMLNS, [], Code) -> decode_muc_user_status_attr_code(__TopXMLNS, Code). encode_muc_user_status(Code, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#user">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_user_status_attr_code(Code, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"status">>, _attrs, _els}. decode_muc_user_status_attr_code(__TopXMLNS, undefined) -> undefined; decode_muc_user_status_attr_code(__TopXMLNS, _val) -> case catch dec_int(_val, 100, 999) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"code">>, <<"status">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_status_attr_code(undefined, _acc) -> _acc; encode_muc_user_status_attr_code(_val, _acc) -> [{<<"code">>, enc_int(_val)} | _acc]. decode_muc_user_continue(__TopXMLNS, __Opts, {xmlel, <<"continue">>, _attrs, _els}) -> Thread = decode_muc_user_continue_attrs(__TopXMLNS, _attrs, undefined), Thread. decode_muc_user_continue_attrs(__TopXMLNS, [{<<"thread">>, _val} | _attrs], _Thread) -> decode_muc_user_continue_attrs(__TopXMLNS, _attrs, _val); decode_muc_user_continue_attrs(__TopXMLNS, [_ | _attrs], Thread) -> decode_muc_user_continue_attrs(__TopXMLNS, _attrs, Thread); decode_muc_user_continue_attrs(__TopXMLNS, [], Thread) -> decode_muc_user_continue_attr_thread(__TopXMLNS, Thread). encode_muc_user_continue(Thread, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#user">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_user_continue_attr_thread(Thread, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"continue">>, _attrs, _els}. decode_muc_user_continue_attr_thread(__TopXMLNS, undefined) -> <<>>; decode_muc_user_continue_attr_thread(__TopXMLNS, _val) -> _val. encode_muc_user_continue_attr_thread(<<>>, _acc) -> _acc; encode_muc_user_continue_attr_thread(_val, _acc) -> [{<<"thread">>, _val} | _acc]. decode_muc_user_actor(__TopXMLNS, __Opts, {xmlel, <<"actor">>, _attrs, _els}) -> {Jid, Nick} = decode_muc_user_actor_attrs(__TopXMLNS, _attrs, undefined, undefined), {muc_actor, Jid, Nick}. decode_muc_user_actor_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Nick) -> decode_muc_user_actor_attrs(__TopXMLNS, _attrs, _val, Nick); decode_muc_user_actor_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], Jid, _Nick) -> decode_muc_user_actor_attrs(__TopXMLNS, _attrs, Jid, _val); decode_muc_user_actor_attrs(__TopXMLNS, [_ | _attrs], Jid, Nick) -> decode_muc_user_actor_attrs(__TopXMLNS, _attrs, Jid, Nick); decode_muc_user_actor_attrs(__TopXMLNS, [], Jid, Nick) -> {decode_muc_user_actor_attr_jid(__TopXMLNS, Jid), decode_muc_user_actor_attr_nick(__TopXMLNS, Nick)}. encode_muc_user_actor({muc_actor, Jid, Nick}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#user">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_user_actor_attr_nick(Nick, encode_muc_user_actor_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"actor">>, _attrs, _els}. decode_muc_user_actor_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_user_actor_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"actor">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_actor_attr_jid(undefined, _acc) -> _acc; encode_muc_user_actor_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_user_actor_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_muc_user_actor_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_user_actor_attr_nick(<<>>, _acc) -> _acc; encode_muc_user_actor_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_muc_user_invite(__TopXMLNS, __Opts, {xmlel, <<"invite">>, _attrs, _els}) -> {Continue, Reason} = decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, undefined, <<>>), {To, From} = decode_muc_user_invite_attrs(__TopXMLNS, _attrs, undefined, undefined), {muc_invite, Reason, From, To, Continue}. decode_muc_user_invite_els(__TopXMLNS, __Opts, [], Continue, Reason) -> {Continue, Reason}; decode_muc_user_invite_els(__TopXMLNS, __Opts, [{xmlel, <<"reason">>, _attrs, _} = _el | _els], Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, Continue, decode_muc_reason(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, Continue, Reason) end; decode_muc_user_invite_els(__TopXMLNS, __Opts, [{xmlel, <<"continue">>, _attrs, _} = _el | _els], Continue, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, decode_muc_user_continue(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el), Reason); _ -> decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, Continue, Reason) end; decode_muc_user_invite_els(__TopXMLNS, __Opts, [_ | _els], Continue, Reason) -> decode_muc_user_invite_els(__TopXMLNS, __Opts, _els, Continue, Reason). decode_muc_user_invite_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], _To, From) -> decode_muc_user_invite_attrs(__TopXMLNS, _attrs, _val, From); decode_muc_user_invite_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], To, _From) -> decode_muc_user_invite_attrs(__TopXMLNS, _attrs, To, _val); decode_muc_user_invite_attrs(__TopXMLNS, [_ | _attrs], To, From) -> decode_muc_user_invite_attrs(__TopXMLNS, _attrs, To, From); decode_muc_user_invite_attrs(__TopXMLNS, [], To, From) -> {decode_muc_user_invite_attr_to(__TopXMLNS, To), decode_muc_user_invite_attr_from(__TopXMLNS, From)}. encode_muc_user_invite({muc_invite, Reason, From, To, Continue}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#user">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_user_invite_$continue'(Continue, __NewTopXMLNS, 'encode_muc_user_invite_$reason'(Reason, __NewTopXMLNS, []))), _attrs = encode_muc_user_invite_attr_from(From, encode_muc_user_invite_attr_to(To, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"invite">>, _attrs, _els}. 'encode_muc_user_invite_$continue'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_invite_$continue'(Continue, __TopXMLNS, _acc) -> [encode_muc_user_continue(Continue, __TopXMLNS) | _acc]. 'encode_muc_user_invite_$reason'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_invite_$reason'(Reason, __TopXMLNS, _acc) -> [encode_muc_reason(Reason, __TopXMLNS) | _acc]. decode_muc_user_invite_attr_to(__TopXMLNS, undefined) -> undefined; decode_muc_user_invite_attr_to(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"invite">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_invite_attr_to(undefined, _acc) -> _acc; encode_muc_user_invite_attr_to(_val, _acc) -> [{<<"to">>, jid:encode(_val)} | _acc]. decode_muc_user_invite_attr_from(__TopXMLNS, undefined) -> undefined; decode_muc_user_invite_attr_from(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"invite">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_invite_attr_from(undefined, _acc) -> _acc; encode_muc_user_invite_attr_from(_val, _acc) -> [{<<"from">>, jid:encode(_val)} | _acc]. decode_muc_destroy(__TopXMLNS, __Opts, {xmlel, <<"destroy">>, _attrs, _els}) -> {Password, Reason} = decode_muc_destroy_els(__TopXMLNS, __Opts, _els, undefined, <<>>), {Jid, Xmlns} = decode_muc_destroy_attrs(__TopXMLNS, _attrs, undefined, undefined), {muc_destroy, Xmlns, Jid, Reason, Password}. decode_muc_destroy_els(__TopXMLNS, __Opts, [], Password, Reason) -> {Password, Reason}; decode_muc_destroy_els(__TopXMLNS, __Opts, [{xmlel, <<"reason">>, _attrs, _} = _el | _els], Password, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, Password, decode_muc_reason(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, Password, decode_muc_reason(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, Password, decode_muc_reason(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, Password, Reason) end; decode_muc_destroy_els(__TopXMLNS, __Opts, [{xmlel, <<"password">>, _attrs, _} = _el | _els], Password, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, decode_muc_password(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el), Reason); <<"http://jabber.org/protocol/muc#user">> -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, decode_muc_password(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el), Reason); <<"http://jabber.org/protocol/muc">> -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, decode_muc_password(<<"http://jabber.org/protocol/muc">>, __Opts, _el), Reason); _ -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, Password, Reason) end; decode_muc_destroy_els(__TopXMLNS, __Opts, [_ | _els], Password, Reason) -> decode_muc_destroy_els(__TopXMLNS, __Opts, _els, Password, Reason). decode_muc_destroy_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Xmlns) -> decode_muc_destroy_attrs(__TopXMLNS, _attrs, _val, Xmlns); decode_muc_destroy_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Jid, _Xmlns) -> decode_muc_destroy_attrs(__TopXMLNS, _attrs, Jid, _val); decode_muc_destroy_attrs(__TopXMLNS, [_ | _attrs], Jid, Xmlns) -> decode_muc_destroy_attrs(__TopXMLNS, _attrs, Jid, Xmlns); decode_muc_destroy_attrs(__TopXMLNS, [], Jid, Xmlns) -> {decode_muc_destroy_attr_jid(__TopXMLNS, Jid), decode_muc_destroy_attr_xmlns(__TopXMLNS, Xmlns)}. encode_muc_destroy({muc_destroy, Xmlns, Jid, Reason, Password}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"http://jabber.org/protocol/muc#user">>, <<"http://jabber.org/protocol/muc#owner">>], __TopXMLNS), _els = lists:reverse('encode_muc_destroy_$password'(Password, __NewTopXMLNS, 'encode_muc_destroy_$reason'(Reason, __NewTopXMLNS, []))), _attrs = encode_muc_destroy_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"destroy">>, _attrs, _els}. 'encode_muc_destroy_$password'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_muc_destroy_$password'(Password, __TopXMLNS, _acc) -> [encode_muc_password(Password, __TopXMLNS) | _acc]. 'encode_muc_destroy_$reason'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_muc_destroy_$reason'(Reason, __TopXMLNS, _acc) -> [encode_muc_reason(Reason, __TopXMLNS) | _acc]. decode_muc_destroy_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_destroy_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"destroy">>, __TopXMLNS}}); _res -> _res end. encode_muc_destroy_attr_jid(undefined, _acc) -> _acc; encode_muc_destroy_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_destroy_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_muc_destroy_attr_xmlns(__TopXMLNS, _val) -> _val. decode_muc_user_decline(__TopXMLNS, __Opts, {xmlel, <<"decline">>, _attrs, _els}) -> Reason = decode_muc_user_decline_els(__TopXMLNS, __Opts, _els, <<>>), {To, From} = decode_muc_user_decline_attrs(__TopXMLNS, _attrs, undefined, undefined), {muc_decline, Reason, From, To}. decode_muc_user_decline_els(__TopXMLNS, __Opts, [], Reason) -> Reason; decode_muc_user_decline_els(__TopXMLNS, __Opts, [{xmlel, <<"reason">>, _attrs, _} = _el | _els], Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/muc#user">> -> decode_muc_user_decline_els(__TopXMLNS, __Opts, _els, decode_muc_reason(<<"http://jabber.org/protocol/muc#user">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#admin">> -> decode_muc_user_decline_els(__TopXMLNS, __Opts, _els, decode_muc_reason(<<"http://jabber.org/protocol/muc#admin">>, __Opts, _el)); <<"http://jabber.org/protocol/muc#owner">> -> decode_muc_user_decline_els(__TopXMLNS, __Opts, _els, decode_muc_reason(<<"http://jabber.org/protocol/muc#owner">>, __Opts, _el)); _ -> decode_muc_user_decline_els(__TopXMLNS, __Opts, _els, Reason) end; decode_muc_user_decline_els(__TopXMLNS, __Opts, [_ | _els], Reason) -> decode_muc_user_decline_els(__TopXMLNS, __Opts, _els, Reason). decode_muc_user_decline_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], _To, From) -> decode_muc_user_decline_attrs(__TopXMLNS, _attrs, _val, From); decode_muc_user_decline_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], To, _From) -> decode_muc_user_decline_attrs(__TopXMLNS, _attrs, To, _val); decode_muc_user_decline_attrs(__TopXMLNS, [_ | _attrs], To, From) -> decode_muc_user_decline_attrs(__TopXMLNS, _attrs, To, From); decode_muc_user_decline_attrs(__TopXMLNS, [], To, From) -> {decode_muc_user_decline_attr_to(__TopXMLNS, To), decode_muc_user_decline_attr_from(__TopXMLNS, From)}. encode_muc_user_decline({muc_decline, Reason, From, To}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc#user">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_user_decline_$reason'(Reason, __NewTopXMLNS, [])), _attrs = encode_muc_user_decline_attr_from(From, encode_muc_user_decline_attr_to(To, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"decline">>, _attrs, _els}. 'encode_muc_user_decline_$reason'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_muc_user_decline_$reason'(Reason, __TopXMLNS, _acc) -> [encode_muc_reason(Reason, __TopXMLNS) | _acc]. decode_muc_user_decline_attr_to(__TopXMLNS, undefined) -> undefined; decode_muc_user_decline_attr_to(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"decline">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_decline_attr_to(undefined, _acc) -> _acc; encode_muc_user_decline_attr_to(_val, _acc) -> [{<<"to">>, jid:encode(_val)} | _acc]. decode_muc_user_decline_attr_from(__TopXMLNS, undefined) -> undefined; decode_muc_user_decline_attr_from(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"decline">>, __TopXMLNS}}); _res -> _res end. encode_muc_user_decline_attr_from(undefined, _acc) -> _acc; encode_muc_user_decline_attr_from(_val, _acc) -> [{<<"from">>, jid:encode(_val)} | _acc]. decode_muc_reason(__TopXMLNS, __Opts, {xmlel, <<"reason">>, _attrs, _els}) -> Cdata = decode_muc_reason_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_muc_reason_els(__TopXMLNS, __Opts, [], Cdata) -> decode_muc_reason_cdata(__TopXMLNS, Cdata); decode_muc_reason_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_muc_reason_els(__TopXMLNS, __Opts, _els, <>); decode_muc_reason_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_muc_reason_els(__TopXMLNS, __Opts, _els, Cdata). encode_muc_reason(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"http://jabber.org/protocol/muc#user">>, <<"http://jabber.org/protocol/muc#admin">>, <<"http://jabber.org/protocol/muc#owner">>], __TopXMLNS), _els = encode_muc_reason_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"reason">>, _attrs, _els}. decode_muc_reason_cdata(__TopXMLNS, <<>>) -> <<>>; decode_muc_reason_cdata(__TopXMLNS, _val) -> _val. encode_muc_reason_cdata(<<>>, _acc) -> _acc; encode_muc_reason_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_muc_history(__TopXMLNS, __Opts, {xmlel, <<"history">>, _attrs, _els}) -> {Maxchars, Maxstanzas, Seconds, Since} = decode_muc_history_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {muc_history, Maxchars, Maxstanzas, Seconds, Since}. decode_muc_history_attrs(__TopXMLNS, [{<<"maxchars">>, _val} | _attrs], _Maxchars, Maxstanzas, Seconds, Since) -> decode_muc_history_attrs(__TopXMLNS, _attrs, _val, Maxstanzas, Seconds, Since); decode_muc_history_attrs(__TopXMLNS, [{<<"maxstanzas">>, _val} | _attrs], Maxchars, _Maxstanzas, Seconds, Since) -> decode_muc_history_attrs(__TopXMLNS, _attrs, Maxchars, _val, Seconds, Since); decode_muc_history_attrs(__TopXMLNS, [{<<"seconds">>, _val} | _attrs], Maxchars, Maxstanzas, _Seconds, Since) -> decode_muc_history_attrs(__TopXMLNS, _attrs, Maxchars, Maxstanzas, _val, Since); decode_muc_history_attrs(__TopXMLNS, [{<<"since">>, _val} | _attrs], Maxchars, Maxstanzas, Seconds, _Since) -> decode_muc_history_attrs(__TopXMLNS, _attrs, Maxchars, Maxstanzas, Seconds, _val); decode_muc_history_attrs(__TopXMLNS, [_ | _attrs], Maxchars, Maxstanzas, Seconds, Since) -> decode_muc_history_attrs(__TopXMLNS, _attrs, Maxchars, Maxstanzas, Seconds, Since); decode_muc_history_attrs(__TopXMLNS, [], Maxchars, Maxstanzas, Seconds, Since) -> {decode_muc_history_attr_maxchars(__TopXMLNS, Maxchars), decode_muc_history_attr_maxstanzas(__TopXMLNS, Maxstanzas), decode_muc_history_attr_seconds(__TopXMLNS, Seconds), decode_muc_history_attr_since(__TopXMLNS, Since)}. encode_muc_history({muc_history, Maxchars, Maxstanzas, Seconds, Since}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/muc">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_history_attr_since(Since, encode_muc_history_attr_seconds(Seconds, encode_muc_history_attr_maxstanzas(Maxstanzas, encode_muc_history_attr_maxchars(Maxchars, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))))), {xmlel, <<"history">>, _attrs, _els}. decode_muc_history_attr_maxchars(__TopXMLNS, undefined) -> undefined; decode_muc_history_attr_maxchars(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"maxchars">>, <<"history">>, __TopXMLNS}}); _res -> _res end. encode_muc_history_attr_maxchars(undefined, _acc) -> _acc; encode_muc_history_attr_maxchars(_val, _acc) -> [{<<"maxchars">>, enc_int(_val)} | _acc]. decode_muc_history_attr_maxstanzas(__TopXMLNS, undefined) -> undefined; decode_muc_history_attr_maxstanzas(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"maxstanzas">>, <<"history">>, __TopXMLNS}}); _res -> _res end. encode_muc_history_attr_maxstanzas(undefined, _acc) -> _acc; encode_muc_history_attr_maxstanzas(_val, _acc) -> [{<<"maxstanzas">>, enc_int(_val)} | _acc]. decode_muc_history_attr_seconds(__TopXMLNS, undefined) -> undefined; decode_muc_history_attr_seconds(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"seconds">>, <<"history">>, __TopXMLNS}}); _res -> _res end. encode_muc_history_attr_seconds(undefined, _acc) -> _acc; encode_muc_history_attr_seconds(_val, _acc) -> [{<<"seconds">>, enc_int(_val)} | _acc]. decode_muc_history_attr_since(__TopXMLNS, undefined) -> undefined; decode_muc_history_attr_since(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"since">>, <<"history">>, __TopXMLNS}}); _res -> _res end. encode_muc_history_attr_since(undefined, _acc) -> _acc; encode_muc_history_attr_since(_val, _acc) -> [{<<"since">>, enc_utc(_val)} | _acc]. xmpp-1.4.4/src/xmpp_sasl_anonymous.erl0000644000232200023220000000252313610066730020467 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Magnus Henoch %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_sasl_anonymous). -behaviour(xmpp_sasl). -protocol({xep, 175, '1.2'}). -export([mech_new/4, mech_step/2]). -record(state, {server = <<"">> :: binary()}). mech_new(Host, _GetPassword, _CheckPassword, _CheckPasswordDigest) -> #state{server = Host}. mech_step(#state{}, _ClientIn) -> User = iolist_to_binary([p1_rand:get_string(), integer_to_binary(p1_time_compat:unique_integer([positive]))]), {ok, [{username, User}, {authzid, User}, {auth_module, anonymous}]}. xmpp-1.4.4/src/xep0013.erl0000644000232200023220000001743713610066730015463 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0013). -compile(export_all). do_decode(<<"offline">>, <<"http://jabber.org/protocol/offline">>, El, Opts) -> decode_offline(<<"http://jabber.org/protocol/offline">>, Opts, El); do_decode(<<"item">>, <<"http://jabber.org/protocol/offline">>, El, Opts) -> decode_offline_item(<<"http://jabber.org/protocol/offline">>, Opts, El); do_decode(<<"fetch">>, <<"http://jabber.org/protocol/offline">>, El, Opts) -> decode_offline_fetch(<<"http://jabber.org/protocol/offline">>, Opts, El); do_decode(<<"purge">>, <<"http://jabber.org/protocol/offline">>, El, Opts) -> decode_offline_purge(<<"http://jabber.org/protocol/offline">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"offline">>, <<"http://jabber.org/protocol/offline">>}, {<<"item">>, <<"http://jabber.org/protocol/offline">>}, {<<"fetch">>, <<"http://jabber.org/protocol/offline">>}, {<<"purge">>, <<"http://jabber.org/protocol/offline">>}]. do_encode({offline_item, _, _} = Item, TopXMLNS) -> encode_offline_item(Item, TopXMLNS); do_encode({offline, _, _, _} = Offline, TopXMLNS) -> encode_offline(Offline, TopXMLNS). do_get_name({offline, _, _, _}) -> <<"offline">>; do_get_name({offline_item, _, _}) -> <<"item">>. do_get_ns({offline, _, _, _}) -> <<"http://jabber.org/protocol/offline">>; do_get_ns({offline_item, _, _}) -> <<"http://jabber.org/protocol/offline">>. pp(offline_item, 2) -> [node, action]; pp(offline, 3) -> [items, purge, fetch]; pp(_, _) -> no. records() -> [{offline_item, 2}, {offline, 3}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). decode_offline(__TopXMLNS, __Opts, {xmlel, <<"offline">>, _attrs, _els}) -> {Items, Purge, Fetch} = decode_offline_els(__TopXMLNS, __Opts, _els, [], false, false), {offline, Items, Purge, Fetch}. decode_offline_els(__TopXMLNS, __Opts, [], Items, Purge, Fetch) -> {lists:reverse(Items), Purge, Fetch}; decode_offline_els(__TopXMLNS, __Opts, [{xmlel, <<"purge">>, _attrs, _} = _el | _els], Items, Purge, Fetch) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/offline">> -> decode_offline_els(__TopXMLNS, __Opts, _els, Items, decode_offline_purge(<<"http://jabber.org/protocol/offline">>, __Opts, _el), Fetch); _ -> decode_offline_els(__TopXMLNS, __Opts, _els, Items, Purge, Fetch) end; decode_offline_els(__TopXMLNS, __Opts, [{xmlel, <<"fetch">>, _attrs, _} = _el | _els], Items, Purge, Fetch) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/offline">> -> decode_offline_els(__TopXMLNS, __Opts, _els, Items, Purge, decode_offline_fetch(<<"http://jabber.org/protocol/offline">>, __Opts, _el)); _ -> decode_offline_els(__TopXMLNS, __Opts, _els, Items, Purge, Fetch) end; decode_offline_els(__TopXMLNS, __Opts, [{xmlel, <<"item">>, _attrs, _} = _el | _els], Items, Purge, Fetch) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/offline">> -> decode_offline_els(__TopXMLNS, __Opts, _els, [decode_offline_item(<<"http://jabber.org/protocol/offline">>, __Opts, _el) | Items], Purge, Fetch); _ -> decode_offline_els(__TopXMLNS, __Opts, _els, Items, Purge, Fetch) end; decode_offline_els(__TopXMLNS, __Opts, [_ | _els], Items, Purge, Fetch) -> decode_offline_els(__TopXMLNS, __Opts, _els, Items, Purge, Fetch). encode_offline({offline, Items, Purge, Fetch}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/offline">>, [], __TopXMLNS), _els = lists:reverse('encode_offline_$items'(Items, __NewTopXMLNS, 'encode_offline_$purge'(Purge, __NewTopXMLNS, 'encode_offline_$fetch'(Fetch, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"offline">>, _attrs, _els}. 'encode_offline_$items'([], __TopXMLNS, _acc) -> _acc; 'encode_offline_$items'([Items | _els], __TopXMLNS, _acc) -> 'encode_offline_$items'(_els, __TopXMLNS, [encode_offline_item(Items, __TopXMLNS) | _acc]). 'encode_offline_$purge'(false, __TopXMLNS, _acc) -> _acc; 'encode_offline_$purge'(Purge, __TopXMLNS, _acc) -> [encode_offline_purge(Purge, __TopXMLNS) | _acc]. 'encode_offline_$fetch'(false, __TopXMLNS, _acc) -> _acc; 'encode_offline_$fetch'(Fetch, __TopXMLNS, _acc) -> [encode_offline_fetch(Fetch, __TopXMLNS) | _acc]. decode_offline_item(__TopXMLNS, __Opts, {xmlel, <<"item">>, _attrs, _els}) -> {Node, Action} = decode_offline_item_attrs(__TopXMLNS, _attrs, undefined, undefined), {offline_item, Node, Action}. decode_offline_item_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node, Action) -> decode_offline_item_attrs(__TopXMLNS, _attrs, _val, Action); decode_offline_item_attrs(__TopXMLNS, [{<<"action">>, _val} | _attrs], Node, _Action) -> decode_offline_item_attrs(__TopXMLNS, _attrs, Node, _val); decode_offline_item_attrs(__TopXMLNS, [_ | _attrs], Node, Action) -> decode_offline_item_attrs(__TopXMLNS, _attrs, Node, Action); decode_offline_item_attrs(__TopXMLNS, [], Node, Action) -> {decode_offline_item_attr_node(__TopXMLNS, Node), decode_offline_item_attr_action(__TopXMLNS, Action)}. encode_offline_item({offline_item, Node, Action}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/offline">>, [], __TopXMLNS), _els = [], _attrs = encode_offline_item_attr_action(Action, encode_offline_item_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"item">>, _attrs, _els}. decode_offline_item_attr_node(__TopXMLNS, undefined) -> <<>>; decode_offline_item_attr_node(__TopXMLNS, _val) -> _val. encode_offline_item_attr_node(<<>>, _acc) -> _acc; encode_offline_item_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_offline_item_attr_action(__TopXMLNS, undefined) -> undefined; decode_offline_item_attr_action(__TopXMLNS, _val) -> case catch dec_enum(_val, [view, remove]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"action">>, <<"item">>, __TopXMLNS}}); _res -> _res end. encode_offline_item_attr_action(undefined, _acc) -> _acc; encode_offline_item_attr_action(_val, _acc) -> [{<<"action">>, enc_enum(_val)} | _acc]. decode_offline_fetch(__TopXMLNS, __Opts, {xmlel, <<"fetch">>, _attrs, _els}) -> true. encode_offline_fetch(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/offline">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"fetch">>, _attrs, _els}. decode_offline_purge(__TopXMLNS, __Opts, {xmlel, <<"purge">>, _attrs, _els}) -> true. encode_offline_purge(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/offline">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"purge">>, _attrs, _els}. xmpp-1.4.4/src/xep0405.erl0000644000232200023220000001507513610066730015464 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0405). -compile(export_all). do_decode(<<"client-leave">>, <<"urn:xmpp:mix:pam:0">>, El, Opts) -> decode_mix_client_leave(<<"urn:xmpp:mix:pam:0">>, Opts, El); do_decode(<<"client-join">>, <<"urn:xmpp:mix:pam:0">>, El, Opts) -> decode_mix_client_join(<<"urn:xmpp:mix:pam:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"client-leave">>, <<"urn:xmpp:mix:pam:0">>}, {<<"client-join">>, <<"urn:xmpp:mix:pam:0">>}]. do_encode({mix_client_join, _, _} = Client_join, TopXMLNS) -> encode_mix_client_join(Client_join, TopXMLNS); do_encode({mix_client_leave, _, _} = Client_leave, TopXMLNS) -> encode_mix_client_leave(Client_leave, TopXMLNS). do_get_name({mix_client_join, _, _}) -> <<"client-join">>; do_get_name({mix_client_leave, _, _}) -> <<"client-leave">>. do_get_ns({mix_client_join, _, _}) -> <<"urn:xmpp:mix:pam:0">>; do_get_ns({mix_client_leave, _, _}) -> <<"urn:xmpp:mix:pam:0">>. pp(mix_client_join, 2) -> [channel, join]; pp(mix_client_leave, 2) -> [channel, leave]; pp(_, _) -> no. records() -> [{mix_client_join, 2}, {mix_client_leave, 2}]. decode_mix_client_leave(__TopXMLNS, __Opts, {xmlel, <<"client-leave">>, _attrs, _els}) -> Leave = decode_mix_client_leave_els(__TopXMLNS, __Opts, _els, error), Channel = decode_mix_client_leave_attrs(__TopXMLNS, _attrs, undefined), {mix_client_leave, Channel, Leave}. decode_mix_client_leave_els(__TopXMLNS, __Opts, [], Leave) -> case Leave of error -> erlang:error({xmpp_codec, {missing_tag, <<"leave">>, __TopXMLNS}}); {value, Leave1} -> Leave1 end; decode_mix_client_leave_els(__TopXMLNS, __Opts, [{xmlel, <<"leave">>, _attrs, _} = _el | _els], Leave) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_client_leave_els(__TopXMLNS, __Opts, _els, {value, xep0369:decode_mix_leave(<<"urn:xmpp:mix:core:0">>, __Opts, _el)}); _ -> decode_mix_client_leave_els(__TopXMLNS, __Opts, _els, Leave) end; decode_mix_client_leave_els(__TopXMLNS, __Opts, [_ | _els], Leave) -> decode_mix_client_leave_els(__TopXMLNS, __Opts, _els, Leave). decode_mix_client_leave_attrs(__TopXMLNS, [{<<"channel">>, _val} | _attrs], _Channel) -> decode_mix_client_leave_attrs(__TopXMLNS, _attrs, _val); decode_mix_client_leave_attrs(__TopXMLNS, [_ | _attrs], Channel) -> decode_mix_client_leave_attrs(__TopXMLNS, _attrs, Channel); decode_mix_client_leave_attrs(__TopXMLNS, [], Channel) -> decode_mix_client_leave_attr_channel(__TopXMLNS, Channel). encode_mix_client_leave({mix_client_leave, Channel, Leave}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:pam:0">>, [], __TopXMLNS), _els = lists:reverse('encode_mix_client_leave_$leave'(Leave, __NewTopXMLNS, [])), _attrs = encode_mix_client_leave_attr_channel(Channel, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"client-leave">>, _attrs, _els}. 'encode_mix_client_leave_$leave'(Leave, __TopXMLNS, _acc) -> [xep0369:encode_mix_leave(Leave, __TopXMLNS) | _acc]. decode_mix_client_leave_attr_channel(__TopXMLNS, undefined) -> undefined; decode_mix_client_leave_attr_channel(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"channel">>, <<"client-leave">>, __TopXMLNS}}); _res -> _res end. encode_mix_client_leave_attr_channel(undefined, _acc) -> _acc; encode_mix_client_leave_attr_channel(_val, _acc) -> [{<<"channel">>, jid:encode(_val)} | _acc]. decode_mix_client_join(__TopXMLNS, __Opts, {xmlel, <<"client-join">>, _attrs, _els}) -> Join = decode_mix_client_join_els(__TopXMLNS, __Opts, _els, error), Channel = decode_mix_client_join_attrs(__TopXMLNS, _attrs, undefined), {mix_client_join, Channel, Join}. decode_mix_client_join_els(__TopXMLNS, __Opts, [], Join) -> case Join of error -> erlang:error({xmpp_codec, {missing_tag, <<"join">>, __TopXMLNS}}); {value, Join1} -> Join1 end; decode_mix_client_join_els(__TopXMLNS, __Opts, [{xmlel, <<"join">>, _attrs, _} = _el | _els], Join) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mix:core:0">> -> decode_mix_client_join_els(__TopXMLNS, __Opts, _els, {value, xep0369:decode_mix_join(<<"urn:xmpp:mix:core:0">>, __Opts, _el)}); _ -> decode_mix_client_join_els(__TopXMLNS, __Opts, _els, Join) end; decode_mix_client_join_els(__TopXMLNS, __Opts, [_ | _els], Join) -> decode_mix_client_join_els(__TopXMLNS, __Opts, _els, Join). decode_mix_client_join_attrs(__TopXMLNS, [{<<"channel">>, _val} | _attrs], _Channel) -> decode_mix_client_join_attrs(__TopXMLNS, _attrs, _val); decode_mix_client_join_attrs(__TopXMLNS, [_ | _attrs], Channel) -> decode_mix_client_join_attrs(__TopXMLNS, _attrs, Channel); decode_mix_client_join_attrs(__TopXMLNS, [], Channel) -> decode_mix_client_join_attr_channel(__TopXMLNS, Channel). encode_mix_client_join({mix_client_join, Channel, Join}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mix:pam:0">>, [], __TopXMLNS), _els = lists:reverse('encode_mix_client_join_$join'(Join, __NewTopXMLNS, [])), _attrs = encode_mix_client_join_attr_channel(Channel, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"client-join">>, _attrs, _els}. 'encode_mix_client_join_$join'(Join, __TopXMLNS, _acc) -> [xep0369:encode_mix_join(Join, __TopXMLNS) | _acc]. decode_mix_client_join_attr_channel(__TopXMLNS, undefined) -> undefined; decode_mix_client_join_attr_channel(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"channel">>, <<"client-join">>, __TopXMLNS}}); _res -> _res end. encode_mix_client_join_attr_channel(undefined, _acc) -> _acc; encode_mix_client_join_attr_channel(_val, _acc) -> [{<<"channel">>, jid:encode(_val)} | _acc]. xmpp-1.4.4/src/rfc6120.erl0000644000232200023220000055566413610066730015457 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(rfc6120). -compile(export_all). do_decode(<<"stream:stream">>, <<"jabber:client">>, El, Opts) -> decode_stream_start(<<"jabber:client">>, Opts, El); do_decode(<<"stream:stream">>, <<"jabber:server">>, El, Opts) -> decode_stream_start(<<"jabber:server">>, Opts, El); do_decode(<<"stream:stream">>, <<"jabber:component:accept">>, El, Opts) -> decode_stream_start(<<"jabber:component:accept">>, Opts, El); do_decode(<<"stream:error">>, <<"jabber:client">>, El, Opts) -> decode_stream_error(<<"jabber:client">>, Opts, El); do_decode(<<"stream:error">>, <<"jabber:server">>, El, Opts) -> decode_stream_error(<<"jabber:server">>, Opts, El); do_decode(<<"stream:error">>, <<"jabber:component:accept">>, El, Opts) -> decode_stream_error(<<"jabber:component:accept">>, Opts, El); do_decode(<<"unsupported-version">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_unsupported_version(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"unsupported-stanza-type">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_unsupported_stanza_type(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"unsupported-feature">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_unsupported_feature(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"unsupported-encoding">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_unsupported_encoding(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"undefined-condition">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_undefined_condition(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"system-shutdown">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_system_shutdown(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"see-other-host">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_see_other_host(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"restricted-xml">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_restricted_xml(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"resource-constraint">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_resource_constraint(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"reset">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_reset(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"remote-connection-failed">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_remote_connection_failed(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"policy-violation">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_policy_violation(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"not-well-formed">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_not_well_formed(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_not_authorized(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"invalid-xml">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_invalid_xml(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"invalid-namespace">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_invalid_namespace(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"invalid-id">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_invalid_id(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"invalid-from">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_invalid_from(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"internal-server-error">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_internal_server_error(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"improper-addressing">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_improper_addressing(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"host-unknown">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_host_unknown(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"host-gone">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_host_gone(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"connection-timeout">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_connection_timeout(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"conflict">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_conflict(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"bad-namespace-prefix">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_bad_namespace_prefix(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"bad-format">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_bad_format(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>, El, Opts) -> decode_stream_error_text(<<"urn:ietf:params:xml:ns:xmpp-streams">>, Opts, El); do_decode(<<"stream:features">>, <<"jabber:client">>, El, Opts) -> decode_stream_features(<<"jabber:client">>, Opts, El); do_decode(<<"stream:features">>, <<"jabber:server">>, El, Opts) -> decode_stream_features(<<"jabber:server">>, Opts, El); do_decode(<<"failure">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>, El, Opts) -> decode_starttls_failure(<<"urn:ietf:params:xml:ns:xmpp-tls">>, Opts, El); do_decode(<<"proceed">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>, El, Opts) -> decode_starttls_proceed(<<"urn:ietf:params:xml:ns:xmpp-tls">>, Opts, El); do_decode(<<"starttls">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>, El, Opts) -> decode_starttls(<<"urn:ietf:params:xml:ns:xmpp-tls">>, Opts, El); do_decode(<<"required">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>, El, Opts) -> decode_starttls_required(<<"urn:ietf:params:xml:ns:xmpp-tls">>, Opts, El); do_decode(<<"mechanisms">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_mechanisms(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"mechanism">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_mechanism(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"failure">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"temporary-auth-failure">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_temporary_auth_failure(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"bad-protocol">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_bad_protocol(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_not_authorized(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"mechanism-too-weak">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_mechanism_too_weak(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"malformed-request">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_malformed_request(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"invalid-mechanism">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_invalid_mechanism(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"invalid-authzid">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_invalid_authzid(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"incorrect-encoding">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_incorrect_encoding(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"encryption-required">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_encryption_required(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"credentials-expired">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_credentials_expired(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"account-disabled">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_account_disabled(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"aborted">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_aborted(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_failure_text(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"success">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_success(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"response">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_response(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"challenge">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_challenge(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"abort">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_abort(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"auth">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>, El, Opts) -> decode_sasl_auth(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, Opts, El); do_decode(<<"bind">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>, El, Opts) -> decode_bind(<<"urn:ietf:params:xml:ns:xmpp-bind">>, Opts, El); do_decode(<<"resource">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>, El, Opts) -> decode_bind_resource(<<"urn:ietf:params:xml:ns:xmpp-bind">>, Opts, El); do_decode(<<"jid">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>, El, Opts) -> decode_bind_jid(<<"urn:ietf:params:xml:ns:xmpp-bind">>, Opts, El); do_decode(<<"error">>, <<"jabber:client">>, El, Opts) -> decode_error(<<"jabber:client">>, Opts, El); do_decode(<<"error">>, <<"jabber:server">>, El, Opts) -> decode_error(<<"jabber:server">>, Opts, El); do_decode(<<"error">>, <<"jabber:component:accept">>, El, Opts) -> decode_error(<<"jabber:component:accept">>, Opts, El); do_decode(<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_text(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"unexpected-request">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_unexpected_request(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"undefined-condition">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_undefined_condition(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"subscription-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_subscription_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"service-unavailable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_service_unavailable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"resource-constraint">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_resource_constraint(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"remote-server-timeout">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_remote_server_timeout(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"remote-server-not-found">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_remote_server_not_found(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"registration-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_registration_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"redirect">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_redirect(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"recipient-unavailable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_recipient_unavailable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"policy-violation">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_policy_violation(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"payment-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_payment_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_not_authorized(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"not-allowed">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_not_allowed(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"not-acceptable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_not_acceptable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"jid-malformed">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_jid_malformed(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"item-not-found">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_item_not_found(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"internal-server-error">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_internal_server_error(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"gone">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_gone(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"forbidden">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_forbidden(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"feature-not-implemented">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_feature_not_implemented(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"conflict">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_conflict(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"bad-request">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>, El, Opts) -> decode_error_bad_request(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, Opts, El); do_decode(<<"presence">>, <<"jabber:client">>, El, Opts) -> decode_presence(<<"jabber:client">>, Opts, El); do_decode(<<"presence">>, <<"jabber:server">>, El, Opts) -> decode_presence(<<"jabber:server">>, Opts, El); do_decode(<<"presence">>, <<"jabber:component:accept">>, El, Opts) -> decode_presence(<<"jabber:component:accept">>, Opts, El); do_decode(<<"priority">>, <<"jabber:client">>, El, Opts) -> decode_presence_priority(<<"jabber:client">>, Opts, El); do_decode(<<"priority">>, <<"jabber:server">>, El, Opts) -> decode_presence_priority(<<"jabber:server">>, Opts, El); do_decode(<<"priority">>, <<"jabber:component:accept">>, El, Opts) -> decode_presence_priority(<<"jabber:component:accept">>, Opts, El); do_decode(<<"status">>, <<"jabber:client">>, El, Opts) -> decode_presence_status(<<"jabber:client">>, Opts, El); do_decode(<<"status">>, <<"jabber:server">>, El, Opts) -> decode_presence_status(<<"jabber:server">>, Opts, El); do_decode(<<"status">>, <<"jabber:component:accept">>, El, Opts) -> decode_presence_status(<<"jabber:component:accept">>, Opts, El); do_decode(<<"show">>, <<"jabber:client">>, El, Opts) -> decode_presence_show(<<"jabber:client">>, Opts, El); do_decode(<<"show">>, <<"jabber:server">>, El, Opts) -> decode_presence_show(<<"jabber:server">>, Opts, El); do_decode(<<"show">>, <<"jabber:component:accept">>, El, Opts) -> decode_presence_show(<<"jabber:component:accept">>, Opts, El); do_decode(<<"message">>, <<"jabber:client">>, El, Opts) -> decode_message(<<"jabber:client">>, Opts, El); do_decode(<<"message">>, <<"jabber:server">>, El, Opts) -> decode_message(<<"jabber:server">>, Opts, El); do_decode(<<"message">>, <<"jabber:component:accept">>, El, Opts) -> decode_message(<<"jabber:component:accept">>, Opts, El); do_decode(<<"thread">>, <<"jabber:client">>, El, Opts) -> decode_message_thread(<<"jabber:client">>, Opts, El); do_decode(<<"thread">>, <<"jabber:server">>, El, Opts) -> decode_message_thread(<<"jabber:server">>, Opts, El); do_decode(<<"thread">>, <<"jabber:component:accept">>, El, Opts) -> decode_message_thread(<<"jabber:component:accept">>, Opts, El); do_decode(<<"body">>, <<"jabber:client">>, El, Opts) -> decode_message_body(<<"jabber:client">>, Opts, El); do_decode(<<"body">>, <<"jabber:server">>, El, Opts) -> decode_message_body(<<"jabber:server">>, Opts, El); do_decode(<<"body">>, <<"jabber:component:accept">>, El, Opts) -> decode_message_body(<<"jabber:component:accept">>, Opts, El); do_decode(<<"subject">>, <<"jabber:client">>, El, Opts) -> decode_message_subject(<<"jabber:client">>, Opts, El); do_decode(<<"subject">>, <<"jabber:server">>, El, Opts) -> decode_message_subject(<<"jabber:server">>, Opts, El); do_decode(<<"subject">>, <<"jabber:component:accept">>, El, Opts) -> decode_message_subject(<<"jabber:component:accept">>, Opts, El); do_decode(<<"iq">>, <<"jabber:client">>, El, Opts) -> decode_iq(<<"jabber:client">>, Opts, El); do_decode(<<"iq">>, <<"jabber:server">>, El, Opts) -> decode_iq(<<"jabber:server">>, Opts, El); do_decode(<<"iq">>, <<"jabber:component:accept">>, El, Opts) -> decode_iq(<<"jabber:component:accept">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"stream:stream">>, <<"jabber:client">>}, {<<"stream:stream">>, <<"jabber:server">>}, {<<"stream:stream">>, <<"jabber:component:accept">>}, {<<"stream:error">>, <<"jabber:client">>}, {<<"stream:error">>, <<"jabber:server">>}, {<<"stream:error">>, <<"jabber:component:accept">>}, {<<"unsupported-version">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"unsupported-stanza-type">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"unsupported-feature">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"unsupported-encoding">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"undefined-condition">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"system-shutdown">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"see-other-host">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"restricted-xml">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"resource-constraint">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"reset">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"remote-connection-failed">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"policy-violation">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"not-well-formed">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"invalid-xml">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"invalid-namespace">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"invalid-id">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"invalid-from">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"internal-server-error">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"improper-addressing">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"host-unknown">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"host-gone">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"connection-timeout">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"conflict">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"bad-namespace-prefix">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"bad-format">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>}, {<<"stream:features">>, <<"jabber:client">>}, {<<"stream:features">>, <<"jabber:server">>}, {<<"failure">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>}, {<<"proceed">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>}, {<<"starttls">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>}, {<<"required">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>}, {<<"mechanisms">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"mechanism">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"failure">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"temporary-auth-failure">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"bad-protocol">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"mechanism-too-weak">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"malformed-request">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"invalid-mechanism">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"invalid-authzid">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"incorrect-encoding">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"encryption-required">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"credentials-expired">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"account-disabled">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"aborted">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"success">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"response">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"challenge">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"abort">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"auth">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>}, {<<"bind">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>}, {<<"resource">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>}, {<<"jid">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>}, {<<"error">>, <<"jabber:client">>}, {<<"error">>, <<"jabber:server">>}, {<<"error">>, <<"jabber:component:accept">>}, {<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"unexpected-request">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"undefined-condition">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"subscription-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"service-unavailable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"resource-constraint">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"remote-server-timeout">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"remote-server-not-found">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"registration-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"redirect">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"recipient-unavailable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"policy-violation">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"payment-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"not-allowed">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"not-acceptable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"jid-malformed">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"item-not-found">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"internal-server-error">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"gone">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"forbidden">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"feature-not-implemented">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"conflict">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"bad-request">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}, {<<"presence">>, <<"jabber:client">>}, {<<"presence">>, <<"jabber:server">>}, {<<"presence">>, <<"jabber:component:accept">>}, {<<"priority">>, <<"jabber:client">>}, {<<"priority">>, <<"jabber:server">>}, {<<"priority">>, <<"jabber:component:accept">>}, {<<"status">>, <<"jabber:client">>}, {<<"status">>, <<"jabber:server">>}, {<<"status">>, <<"jabber:component:accept">>}, {<<"show">>, <<"jabber:client">>}, {<<"show">>, <<"jabber:server">>}, {<<"show">>, <<"jabber:component:accept">>}, {<<"message">>, <<"jabber:client">>}, {<<"message">>, <<"jabber:server">>}, {<<"message">>, <<"jabber:component:accept">>}, {<<"thread">>, <<"jabber:client">>}, {<<"thread">>, <<"jabber:server">>}, {<<"thread">>, <<"jabber:component:accept">>}, {<<"body">>, <<"jabber:client">>}, {<<"body">>, <<"jabber:server">>}, {<<"body">>, <<"jabber:component:accept">>}, {<<"subject">>, <<"jabber:client">>}, {<<"subject">>, <<"jabber:server">>}, {<<"subject">>, <<"jabber:component:accept">>}, {<<"iq">>, <<"jabber:client">>}, {<<"iq">>, <<"jabber:server">>}, {<<"iq">>, <<"jabber:component:accept">>}]. do_encode({iq, _, _, _, _, _, _, _} = Iq, TopXMLNS) -> encode_iq(Iq, TopXMLNS); do_encode({message_thread, _, _} = Thread, TopXMLNS) -> encode_message_thread(Thread, TopXMLNS); do_encode({message, _, _, _, _, _, _, _, _, _, _} = Message, TopXMLNS) -> encode_message(Message, TopXMLNS); do_encode({presence, _, _, _, _, _, _, _, _, _, _} = Presence, TopXMLNS) -> encode_presence(Presence, TopXMLNS); do_encode({gone, _} = Gone, TopXMLNS) -> encode_error_gone(Gone, TopXMLNS); do_encode({redirect, _} = Redirect, TopXMLNS) -> encode_error_redirect(Redirect, TopXMLNS); do_encode({stanza_error, _, _, _, _, _, _} = Error, TopXMLNS) -> encode_error(Error, TopXMLNS); do_encode({bind, _, _} = Bind, TopXMLNS) -> encode_bind(Bind, TopXMLNS); do_encode({sasl_auth, _, _} = Auth, TopXMLNS) -> encode_sasl_auth(Auth, TopXMLNS); do_encode({sasl_abort} = Abort, TopXMLNS) -> encode_sasl_abort(Abort, TopXMLNS); do_encode({sasl_challenge, _} = Challenge, TopXMLNS) -> encode_sasl_challenge(Challenge, TopXMLNS); do_encode({sasl_response, _} = Response, TopXMLNS) -> encode_sasl_response(Response, TopXMLNS); do_encode({sasl_success, _} = Success, TopXMLNS) -> encode_sasl_success(Success, TopXMLNS); do_encode({sasl_failure, _, _} = Failure, TopXMLNS) -> encode_sasl_failure(Failure, TopXMLNS); do_encode({sasl_mechanisms, _} = Mechanisms, TopXMLNS) -> encode_sasl_mechanisms(Mechanisms, TopXMLNS); do_encode({starttls, _} = Starttls, TopXMLNS) -> encode_starttls(Starttls, TopXMLNS); do_encode({starttls_proceed} = Proceed, TopXMLNS) -> encode_starttls_proceed(Proceed, TopXMLNS); do_encode({starttls_failure} = Failure, TopXMLNS) -> encode_starttls_failure(Failure, TopXMLNS); do_encode({stream_features, _} = Stream_features, TopXMLNS) -> encode_stream_features(Stream_features, TopXMLNS); do_encode({text, _, _} = Text, TopXMLNS) -> encode_stream_error_text(Text, TopXMLNS); do_encode({'see-other-host', _} = See_other_host, TopXMLNS) -> encode_stream_error_see_other_host(See_other_host, TopXMLNS); do_encode({stream_error, _, _} = Stream_error, TopXMLNS) -> encode_stream_error(Stream_error, TopXMLNS); do_encode({stream_start, _, _, _, _, _, _, _, _} = Stream_stream, TopXMLNS) -> encode_stream_start(Stream_stream, TopXMLNS). do_get_name({bind, _, _}) -> <<"bind">>; do_get_name({gone, _}) -> <<"gone">>; do_get_name({iq, _, _, _, _, _, _, _}) -> <<"iq">>; do_get_name({message, _, _, _, _, _, _, _, _, _, _}) -> <<"message">>; do_get_name({message_thread, _, _}) -> <<"thread">>; do_get_name({presence, _, _, _, _, _, _, _, _, _, _}) -> <<"presence">>; do_get_name({redirect, _}) -> <<"redirect">>; do_get_name({sasl_abort}) -> <<"abort">>; do_get_name({sasl_auth, _, _}) -> <<"auth">>; do_get_name({sasl_challenge, _}) -> <<"challenge">>; do_get_name({sasl_failure, _, _}) -> <<"failure">>; do_get_name({sasl_mechanisms, _}) -> <<"mechanisms">>; do_get_name({sasl_response, _}) -> <<"response">>; do_get_name({sasl_success, _}) -> <<"success">>; do_get_name({'see-other-host', _}) -> <<"see-other-host">>; do_get_name({stanza_error, _, _, _, _, _, _}) -> <<"error">>; do_get_name({starttls, _}) -> <<"starttls">>; do_get_name({starttls_failure}) -> <<"failure">>; do_get_name({starttls_proceed}) -> <<"proceed">>; do_get_name({stream_error, _, _}) -> <<"stream:error">>; do_get_name({stream_features, _}) -> <<"stream:features">>; do_get_name({stream_start, _, _, _, _, _, _, _, _}) -> <<"stream:stream">>; do_get_name({text, _, _}) -> <<"text">>. do_get_ns({bind, _, _}) -> <<"urn:ietf:params:xml:ns:xmpp-bind">>; do_get_ns({gone, _}) -> <<"urn:ietf:params:xml:ns:xmpp-stanzas">>; do_get_ns({iq, _, _, _, _, _, _, _}) -> <<"jabber:client">>; do_get_ns({message, _, _, _, _, _, _, _, _, _, _}) -> <<"jabber:client">>; do_get_ns({message_thread, _, _}) -> <<"jabber:client">>; do_get_ns({presence, _, _, _, _, _, _, _, _, _, _}) -> <<"jabber:client">>; do_get_ns({redirect, _}) -> <<"urn:ietf:params:xml:ns:xmpp-stanzas">>; do_get_ns({sasl_abort}) -> <<"urn:ietf:params:xml:ns:xmpp-sasl">>; do_get_ns({sasl_auth, _, _}) -> <<"urn:ietf:params:xml:ns:xmpp-sasl">>; do_get_ns({sasl_challenge, _}) -> <<"urn:ietf:params:xml:ns:xmpp-sasl">>; do_get_ns({sasl_failure, _, _}) -> <<"urn:ietf:params:xml:ns:xmpp-sasl">>; do_get_ns({sasl_mechanisms, _}) -> <<"urn:ietf:params:xml:ns:xmpp-sasl">>; do_get_ns({sasl_response, _}) -> <<"urn:ietf:params:xml:ns:xmpp-sasl">>; do_get_ns({sasl_success, _}) -> <<"urn:ietf:params:xml:ns:xmpp-sasl">>; do_get_ns({'see-other-host', _}) -> <<"urn:ietf:params:xml:ns:xmpp-streams">>; do_get_ns({stanza_error, _, _, _, _, _, _}) -> <<"jabber:client">>; do_get_ns({starttls, _}) -> <<"urn:ietf:params:xml:ns:xmpp-tls">>; do_get_ns({starttls_failure}) -> <<"urn:ietf:params:xml:ns:xmpp-tls">>; do_get_ns({starttls_proceed}) -> <<"urn:ietf:params:xml:ns:xmpp-tls">>; do_get_ns({stream_error, _, _}) -> <<"jabber:client">>; do_get_ns({stream_features, _}) -> <<"jabber:client">>; do_get_ns({stream_start, _, _, _, _, Xmlns, _, _, _}) -> Xmlns. get_els({iq, _id, _type, _lang, _from, _to, _sub_els, _meta}) -> _sub_els; get_els({message, _id, _type, _lang, _from, _to, _subject, _body, _thread, _sub_els, _meta}) -> _sub_els; get_els({presence, _id, _type, _lang, _from, _to, _show, _status, _priority, _sub_els, _meta}) -> _sub_els; get_els({stanza_error, _type, _code, _by, _reason, _text, _sub_els}) -> _sub_els; get_els({stream_features, _sub_els}) -> _sub_els. set_els({iq, _id, _type, _lang, _from, _to, _, _meta}, _sub_els) -> {iq, _id, _type, _lang, _from, _to, _sub_els, _meta}; set_els({message, _id, _type, _lang, _from, _to, _subject, _body, _thread, _, _meta}, _sub_els) -> {message, _id, _type, _lang, _from, _to, _subject, _body, _thread, _sub_els, _meta}; set_els({presence, _id, _type, _lang, _from, _to, _show, _status, _priority, _, _meta}, _sub_els) -> {presence, _id, _type, _lang, _from, _to, _show, _status, _priority, _sub_els, _meta}; set_els({stanza_error, _type, _code, _by, _reason, _text, _}, _sub_els) -> {stanza_error, _type, _code, _by, _reason, _text, _sub_els}; set_els({stream_features, _}, _sub_els) -> {stream_features, _sub_els}. pp(iq, 7) -> [id, type, lang, from, to, sub_els, meta]; pp(message_thread, 2) -> [parent, data]; pp(message, 10) -> [id, type, lang, from, to, subject, body, thread, sub_els, meta]; pp(presence, 10) -> [id, type, lang, from, to, show, status, priority, sub_els, meta]; pp(gone, 1) -> [uri]; pp(redirect, 1) -> [uri]; pp(stanza_error, 6) -> [type, code, by, reason, text, sub_els]; pp(bind, 2) -> [jid, resource]; pp(sasl_auth, 2) -> [mechanism, text]; pp(sasl_abort, 0) -> []; pp(sasl_challenge, 1) -> [text]; pp(sasl_response, 1) -> [text]; pp(sasl_success, 1) -> [text]; pp(sasl_failure, 2) -> [reason, text]; pp(sasl_mechanisms, 1) -> [list]; pp(starttls, 1) -> [required]; pp(starttls_proceed, 0) -> []; pp(starttls_failure, 0) -> []; pp(stream_features, 1) -> [sub_els]; pp(text, 2) -> [lang, data]; pp('see-other-host', 1) -> [host]; pp(stream_error, 2) -> [reason, text]; pp(stream_start, 8) -> [from, to, id, version, xmlns, stream_xmlns, db_xmlns, lang]; pp(_, _) -> no. records() -> [{iq, 7}, {message_thread, 2}, {message, 10}, {presence, 10}, {gone, 1}, {redirect, 1}, {stanza_error, 6}, {bind, 2}, {sasl_auth, 2}, {sasl_abort, 0}, {sasl_challenge, 1}, {sasl_response, 1}, {sasl_success, 1}, {sasl_failure, 2}, {sasl_mechanisms, 1}, {starttls, 1}, {starttls_proceed, 0}, {starttls_failure, 0}, {stream_features, 1}, {text, 2}, {'see-other-host', 1}, {stream_error, 2}, {stream_start, 8}]. check_resource(R) -> case jid:resourceprep(R) of error -> erlang:error(badarg); _ -> R end. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_host_port(<<$[, T/binary>>) -> [IP, <<$:, Port/binary>>] = binary:split(T, <<$]>>), {dec_ip(IP), dec_int(Port, 0, 65535)}; dec_host_port(S) -> case binary:split(S, <<$:>>) of [S] -> try dec_ip(S) catch _:_ -> S end; [S, P] -> {try dec_ip(S) catch _:_ -> S end, dec_int(P, 0, 65535)} end. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. dec_ip(S) -> {ok, Addr} = inet_parse:address(binary_to_list(S)), Addr. dec_message_type(<<"chat">>) -> chat; dec_message_type(<<"groupchat">>) -> groupchat; dec_message_type(<<"headline">>) -> headline; dec_message_type(<<"error">>) -> error; dec_message_type(_) -> normal. dec_version(S) -> [Major, Minor] = binary:split(S, <<$.>>), {binary_to_integer(Major), binary_to_integer(Minor)}. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_host_port(Host) when is_binary(Host) -> Host; enc_host_port({Addr, Port}) when is_tuple(Addr) -> enc_host_port({enc_host_port(Addr), Port}); enc_host_port({Host, Port}) -> <>; enc_host_port({_, _, _, _} = IPv4) -> enc_ip(IPv4); enc_host_port({0, 0, 0, 0, 0, 65535, _, _} = IP) -> enc_ip(IP); enc_host_port({_, _, _, _, _, _, _, _} = IPv6) -> <<$[, (enc_ip(IPv6))/binary, $]>>. enc_int(Int) -> erlang:integer_to_binary(Int). enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). enc_version({Maj, Min}) -> <<(integer_to_binary(Maj))/binary, $., (integer_to_binary(Min))/binary>>. decode_stream_start(__TopXMLNS, __Opts, {xmlel, <<"stream:stream">>, _attrs, _els}) -> {From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id} = decode_stream_start_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined), {stream_start, From, To, Id, Version, Xmlns, Stream_xmlns, Db_xmlns, Lang}. decode_stream_start_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], _From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, _val, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id); decode_stream_start_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], From, _To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, _val, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id); decode_stream_start_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], From, To, _Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, To, _val, Stream_xmlns, Db_xmlns, Lang, Version, Id); decode_stream_start_attrs(__TopXMLNS, [{<<"xmlns:stream">>, _val} | _attrs], From, To, Xmlns, _Stream_xmlns, Db_xmlns, Lang, Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, To, Xmlns, _val, Db_xmlns, Lang, Version, Id); decode_stream_start_attrs(__TopXMLNS, [{<<"xmlns:db">>, _val} | _attrs], From, To, Xmlns, Stream_xmlns, _Db_xmlns, Lang, Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, To, Xmlns, Stream_xmlns, _val, Lang, Version, Id); decode_stream_start_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], From, To, Xmlns, Stream_xmlns, Db_xmlns, _Lang, Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, To, Xmlns, Stream_xmlns, Db_xmlns, _val, Version, Id); decode_stream_start_attrs(__TopXMLNS, [{<<"version">>, _val} | _attrs], From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, _Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, _val, Id); decode_stream_start_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, _Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, _val); decode_stream_start_attrs(__TopXMLNS, [_ | _attrs], From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id) -> decode_stream_start_attrs(__TopXMLNS, _attrs, From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id); decode_stream_start_attrs(__TopXMLNS, [], From, To, Xmlns, Stream_xmlns, Db_xmlns, Lang, Version, Id) -> {decode_stream_start_attr_from(__TopXMLNS, From), decode_stream_start_attr_to(__TopXMLNS, To), decode_stream_start_attr_xmlns(__TopXMLNS, Xmlns), 'decode_stream_start_attr_xmlns:stream'(__TopXMLNS, Stream_xmlns), 'decode_stream_start_attr_xmlns:db'(__TopXMLNS, Db_xmlns), 'decode_stream_start_attr_xml:lang'(__TopXMLNS, Lang), decode_stream_start_attr_version(__TopXMLNS, Version), decode_stream_start_attr_id(__TopXMLNS, Id)}. encode_stream_start({stream_start, From, To, Id, Version, Xmlns, Stream_xmlns, Db_xmlns, Lang}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = [], _attrs = encode_stream_start_attr_id(Id, encode_stream_start_attr_version(Version, 'encode_stream_start_attr_xml:lang'(Lang, 'encode_stream_start_attr_xmlns:db'(Db_xmlns, 'encode_stream_start_attr_xmlns:stream'(Stream_xmlns, encode_stream_start_attr_to(To, encode_stream_start_attr_from(From, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))))), {xmlel, <<"stream:stream">>, _attrs, _els}. decode_stream_start_attr_from(__TopXMLNS, undefined) -> undefined; decode_stream_start_attr_from(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"stream:stream">>, __TopXMLNS}}); _res -> _res end. encode_stream_start_attr_from(undefined, _acc) -> _acc; encode_stream_start_attr_from(_val, _acc) -> [{<<"from">>, jid:encode(_val)} | _acc]. decode_stream_start_attr_to(__TopXMLNS, undefined) -> undefined; decode_stream_start_attr_to(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"stream:stream">>, __TopXMLNS}}); _res -> _res end. encode_stream_start_attr_to(undefined, _acc) -> _acc; encode_stream_start_attr_to(_val, _acc) -> [{<<"to">>, jid:encode(_val)} | _acc]. decode_stream_start_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_stream_start_attr_xmlns(__TopXMLNS, _val) -> _val. 'decode_stream_start_attr_xmlns:stream'(__TopXMLNS, undefined) -> <<>>; 'decode_stream_start_attr_xmlns:stream'(__TopXMLNS, _val) -> _val. 'encode_stream_start_attr_xmlns:stream'(<<>>, _acc) -> _acc; 'encode_stream_start_attr_xmlns:stream'(_val, _acc) -> [{<<"xmlns:stream">>, _val} | _acc]. 'decode_stream_start_attr_xmlns:db'(__TopXMLNS, undefined) -> <<>>; 'decode_stream_start_attr_xmlns:db'(__TopXMLNS, _val) -> _val. 'encode_stream_start_attr_xmlns:db'(<<>>, _acc) -> _acc; 'encode_stream_start_attr_xmlns:db'(_val, _acc) -> [{<<"xmlns:db">>, _val} | _acc]. 'decode_stream_start_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_stream_start_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"stream:stream">>, __TopXMLNS}}); _res -> _res end. 'encode_stream_start_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_stream_start_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_stream_start_attr_version(__TopXMLNS, undefined) -> undefined; decode_stream_start_attr_version(__TopXMLNS, _val) -> case catch dec_version(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"version">>, <<"stream:stream">>, __TopXMLNS}}); _res -> _res end. encode_stream_start_attr_version(undefined, _acc) -> _acc; encode_stream_start_attr_version(_val, _acc) -> [{<<"version">>, enc_version(_val)} | _acc]. decode_stream_start_attr_id(__TopXMLNS, undefined) -> <<>>; decode_stream_start_attr_id(__TopXMLNS, _val) -> _val. encode_stream_start_attr_id(<<>>, _acc) -> _acc; encode_stream_start_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_stream_error(__TopXMLNS, __Opts, {xmlel, <<"stream:error">>, _attrs, _els}) -> {Text, Reason} = decode_stream_error_els(__TopXMLNS, __Opts, _els, [], undefined), {stream_error, Reason, Text}. decode_stream_error_els(__TopXMLNS, __Opts, [], Text, Reason) -> {lists:reverse(Text), Reason}; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"text">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, [decode_stream_error_text(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el) | Text], Reason); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"bad-format">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_bad_format(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"bad-namespace-prefix">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_bad_namespace_prefix(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"conflict">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_conflict(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"connection-timeout">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_connection_timeout(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"host-gone">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_host_gone(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"host-unknown">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_host_unknown(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"improper-addressing">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_improper_addressing(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"internal-server-error">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_internal_server_error(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"invalid-from">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_invalid_from(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"invalid-id">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_invalid_id(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"invalid-namespace">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_invalid_namespace(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"invalid-xml">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_invalid_xml(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"not-authorized">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_not_authorized(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"not-well-formed">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_not_well_formed(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"policy-violation">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_policy_violation(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"remote-connection-failed">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_remote_connection_failed(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"reset">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_reset(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"resource-constraint">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_resource_constraint(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"restricted-xml">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_restricted_xml(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"see-other-host">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_see_other_host(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"system-shutdown">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_system_shutdown(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"undefined-condition">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_undefined_condition(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"unsupported-encoding">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_unsupported_encoding(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"unsupported-feature">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_unsupported_feature(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"unsupported-stanza-type">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_unsupported_stanza_type(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [{xmlel, <<"unsupported-version">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-streams">> -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, decode_stream_error_unsupported_version(<<"urn:ietf:params:xml:ns:xmpp-streams">>, __Opts, _el)); _ -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_stream_error_els(__TopXMLNS, __Opts, [_ | _els], Text, Reason) -> decode_stream_error_els(__TopXMLNS, __Opts, _els, Text, Reason). encode_stream_error({stream_error, Reason, Text}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = lists:reverse('encode_stream_error_$text'(Text, __NewTopXMLNS, 'encode_stream_error_$reason'(Reason, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"stream:error">>, _attrs, _els}. 'encode_stream_error_$text'([], __TopXMLNS, _acc) -> _acc; 'encode_stream_error_$text'([Text | _els], __TopXMLNS, _acc) -> 'encode_stream_error_$text'(_els, __TopXMLNS, [encode_stream_error_text(Text, __TopXMLNS) | _acc]). 'encode_stream_error_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_stream_error_$reason'('bad-format' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_bad_format(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('bad-namespace-prefix' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_bad_namespace_prefix(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'(conflict = Reason, __TopXMLNS, _acc) -> [encode_stream_error_conflict(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('connection-timeout' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_connection_timeout(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('host-gone' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_host_gone(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('host-unknown' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_host_unknown(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('improper-addressing' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_improper_addressing(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('internal-server-error' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_internal_server_error(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('invalid-from' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_invalid_from(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('invalid-id' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_invalid_id(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('invalid-namespace' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_invalid_namespace(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('invalid-xml' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_invalid_xml(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('not-authorized' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_not_authorized(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('not-well-formed' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_not_well_formed(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('policy-violation' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_policy_violation(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('remote-connection-failed' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_remote_connection_failed(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'(reset = Reason, __TopXMLNS, _acc) -> [encode_stream_error_reset(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('resource-constraint' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_resource_constraint(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('restricted-xml' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_restricted_xml(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'({'see-other-host', _} = Reason, __TopXMLNS, _acc) -> [encode_stream_error_see_other_host(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('system-shutdown' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_system_shutdown(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('undefined-condition' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_undefined_condition(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('unsupported-encoding' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_unsupported_encoding(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('unsupported-feature' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_unsupported_feature(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('unsupported-stanza-type' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_unsupported_stanza_type(Reason, __TopXMLNS) | _acc]; 'encode_stream_error_$reason'('unsupported-version' = Reason, __TopXMLNS, _acc) -> [encode_stream_error_unsupported_version(Reason, __TopXMLNS) | _acc]. decode_stream_error_unsupported_version(__TopXMLNS, __Opts, {xmlel, <<"unsupported-version">>, _attrs, _els}) -> 'unsupported-version'. encode_stream_error_unsupported_version('unsupported-version', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-version">>, _attrs, _els}. decode_stream_error_unsupported_stanza_type(__TopXMLNS, __Opts, {xmlel, <<"unsupported-stanza-type">>, _attrs, _els}) -> 'unsupported-stanza-type'. encode_stream_error_unsupported_stanza_type('unsupported-stanza-type', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-stanza-type">>, _attrs, _els}. decode_stream_error_unsupported_feature(__TopXMLNS, __Opts, {xmlel, <<"unsupported-feature">>, _attrs, _els}) -> 'unsupported-feature'. encode_stream_error_unsupported_feature('unsupported-feature', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-feature">>, _attrs, _els}. decode_stream_error_unsupported_encoding(__TopXMLNS, __Opts, {xmlel, <<"unsupported-encoding">>, _attrs, _els}) -> 'unsupported-encoding'. encode_stream_error_unsupported_encoding('unsupported-encoding', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unsupported-encoding">>, _attrs, _els}. decode_stream_error_undefined_condition(__TopXMLNS, __Opts, {xmlel, <<"undefined-condition">>, _attrs, _els}) -> 'undefined-condition'. encode_stream_error_undefined_condition('undefined-condition', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"undefined-condition">>, _attrs, _els}. decode_stream_error_system_shutdown(__TopXMLNS, __Opts, {xmlel, <<"system-shutdown">>, _attrs, _els}) -> 'system-shutdown'. encode_stream_error_system_shutdown('system-shutdown', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"system-shutdown">>, _attrs, _els}. decode_stream_error_see_other_host(__TopXMLNS, __Opts, {xmlel, <<"see-other-host">>, _attrs, _els}) -> Host = decode_stream_error_see_other_host_els(__TopXMLNS, __Opts, _els, <<>>), {'see-other-host', Host}. decode_stream_error_see_other_host_els(__TopXMLNS, __Opts, [], Host) -> decode_stream_error_see_other_host_cdata(__TopXMLNS, Host); decode_stream_error_see_other_host_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Host) -> decode_stream_error_see_other_host_els(__TopXMLNS, __Opts, _els, <>); decode_stream_error_see_other_host_els(__TopXMLNS, __Opts, [_ | _els], Host) -> decode_stream_error_see_other_host_els(__TopXMLNS, __Opts, _els, Host). encode_stream_error_see_other_host({'see-other-host', Host}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = encode_stream_error_see_other_host_cdata(Host, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"see-other-host">>, _attrs, _els}. decode_stream_error_see_other_host_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"see-other-host">>, __TopXMLNS}}); decode_stream_error_see_other_host_cdata(__TopXMLNS, _val) -> case catch dec_host_port(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"see-other-host">>, __TopXMLNS}}); _res -> _res end. encode_stream_error_see_other_host_cdata(_val, _acc) -> [{xmlcdata, enc_host_port(_val)} | _acc]. decode_stream_error_restricted_xml(__TopXMLNS, __Opts, {xmlel, <<"restricted-xml">>, _attrs, _els}) -> 'restricted-xml'. encode_stream_error_restricted_xml('restricted-xml', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"restricted-xml">>, _attrs, _els}. decode_stream_error_resource_constraint(__TopXMLNS, __Opts, {xmlel, <<"resource-constraint">>, _attrs, _els}) -> 'resource-constraint'. encode_stream_error_resource_constraint('resource-constraint', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"resource-constraint">>, _attrs, _els}. decode_stream_error_reset(__TopXMLNS, __Opts, {xmlel, <<"reset">>, _attrs, _els}) -> reset. encode_stream_error_reset(reset, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"reset">>, _attrs, _els}. decode_stream_error_remote_connection_failed(__TopXMLNS, __Opts, {xmlel, <<"remote-connection-failed">>, _attrs, _els}) -> 'remote-connection-failed'. encode_stream_error_remote_connection_failed('remote-connection-failed', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"remote-connection-failed">>, _attrs, _els}. decode_stream_error_policy_violation(__TopXMLNS, __Opts, {xmlel, <<"policy-violation">>, _attrs, _els}) -> 'policy-violation'. encode_stream_error_policy_violation('policy-violation', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"policy-violation">>, _attrs, _els}. decode_stream_error_not_well_formed(__TopXMLNS, __Opts, {xmlel, <<"not-well-formed">>, _attrs, _els}) -> 'not-well-formed'. encode_stream_error_not_well_formed('not-well-formed', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-well-formed">>, _attrs, _els}. decode_stream_error_not_authorized(__TopXMLNS, __Opts, {xmlel, <<"not-authorized">>, _attrs, _els}) -> 'not-authorized'. encode_stream_error_not_authorized('not-authorized', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-authorized">>, _attrs, _els}. decode_stream_error_invalid_xml(__TopXMLNS, __Opts, {xmlel, <<"invalid-xml">>, _attrs, _els}) -> 'invalid-xml'. encode_stream_error_invalid_xml('invalid-xml', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-xml">>, _attrs, _els}. decode_stream_error_invalid_namespace(__TopXMLNS, __Opts, {xmlel, <<"invalid-namespace">>, _attrs, _els}) -> 'invalid-namespace'. encode_stream_error_invalid_namespace('invalid-namespace', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-namespace">>, _attrs, _els}. decode_stream_error_invalid_id(__TopXMLNS, __Opts, {xmlel, <<"invalid-id">>, _attrs, _els}) -> 'invalid-id'. encode_stream_error_invalid_id('invalid-id', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-id">>, _attrs, _els}. decode_stream_error_invalid_from(__TopXMLNS, __Opts, {xmlel, <<"invalid-from">>, _attrs, _els}) -> 'invalid-from'. encode_stream_error_invalid_from('invalid-from', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-from">>, _attrs, _els}. decode_stream_error_internal_server_error(__TopXMLNS, __Opts, {xmlel, <<"internal-server-error">>, _attrs, _els}) -> 'internal-server-error'. encode_stream_error_internal_server_error('internal-server-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"internal-server-error">>, _attrs, _els}. decode_stream_error_improper_addressing(__TopXMLNS, __Opts, {xmlel, <<"improper-addressing">>, _attrs, _els}) -> 'improper-addressing'. encode_stream_error_improper_addressing('improper-addressing', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"improper-addressing">>, _attrs, _els}. decode_stream_error_host_unknown(__TopXMLNS, __Opts, {xmlel, <<"host-unknown">>, _attrs, _els}) -> 'host-unknown'. encode_stream_error_host_unknown('host-unknown', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"host-unknown">>, _attrs, _els}. decode_stream_error_host_gone(__TopXMLNS, __Opts, {xmlel, <<"host-gone">>, _attrs, _els}) -> 'host-gone'. encode_stream_error_host_gone('host-gone', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"host-gone">>, _attrs, _els}. decode_stream_error_connection_timeout(__TopXMLNS, __Opts, {xmlel, <<"connection-timeout">>, _attrs, _els}) -> 'connection-timeout'. encode_stream_error_connection_timeout('connection-timeout', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"connection-timeout">>, _attrs, _els}. decode_stream_error_conflict(__TopXMLNS, __Opts, {xmlel, <<"conflict">>, _attrs, _els}) -> conflict. encode_stream_error_conflict(conflict, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"conflict">>, _attrs, _els}. decode_stream_error_bad_namespace_prefix(__TopXMLNS, __Opts, {xmlel, <<"bad-namespace-prefix">>, _attrs, _els}) -> 'bad-namespace-prefix'. encode_stream_error_bad_namespace_prefix('bad-namespace-prefix', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"bad-namespace-prefix">>, _attrs, _els}. decode_stream_error_bad_format(__TopXMLNS, __Opts, {xmlel, <<"bad-format">>, _attrs, _els}) -> 'bad-format'. encode_stream_error_bad_format('bad-format', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"bad-format">>, _attrs, _els}. decode_stream_error_text(__TopXMLNS, __Opts, {xmlel, <<"text">>, _attrs, _els}) -> Data = decode_stream_error_text_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_stream_error_text_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_stream_error_text_els(__TopXMLNS, __Opts, [], Data) -> decode_stream_error_text_cdata(__TopXMLNS, Data); decode_stream_error_text_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_stream_error_text_els(__TopXMLNS, __Opts, _els, <>); decode_stream_error_text_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_stream_error_text_els(__TopXMLNS, __Opts, _els, Data). decode_stream_error_text_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_stream_error_text_attrs(__TopXMLNS, _attrs, _val); decode_stream_error_text_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_stream_error_text_attrs(__TopXMLNS, _attrs, Lang); decode_stream_error_text_attrs(__TopXMLNS, [], Lang) -> 'decode_stream_error_text_attr_xml:lang'(__TopXMLNS, Lang). encode_stream_error_text({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-streams">>, [], __TopXMLNS), _els = encode_stream_error_text_cdata(Data, []), _attrs = 'encode_stream_error_text_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"text">>, _attrs, _els}. 'decode_stream_error_text_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_stream_error_text_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"text">>, __TopXMLNS}}); _res -> _res end. 'encode_stream_error_text_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_stream_error_text_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_stream_error_text_cdata(__TopXMLNS, <<>>) -> <<>>; decode_stream_error_text_cdata(__TopXMLNS, _val) -> _val. encode_stream_error_text_cdata(<<>>, _acc) -> _acc; encode_stream_error_text_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_stream_features(__TopXMLNS, __Opts, {xmlel, <<"stream:features">>, _attrs, _els}) -> __Els = decode_stream_features_els(__TopXMLNS, __Opts, _els, []), {stream_features, __Els}. decode_stream_features_els(__TopXMLNS, __Opts, [], __Els) -> lists:reverse(__Els); decode_stream_features_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_stream_features_els(__TopXMLNS, __Opts, _els, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_stream_features_els(__TopXMLNS, __Opts, _els, [_el | __Els]); Mod -> decode_stream_features_els(__TopXMLNS, __Opts, _els, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_stream_features_els(__TopXMLNS, __Opts, [_ | _els], __Els) -> decode_stream_features_els(__TopXMLNS, __Opts, _els, __Els). encode_stream_features({stream_features, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"stream:features">>, _attrs, _els}. decode_starttls_failure(__TopXMLNS, __Opts, {xmlel, <<"failure">>, _attrs, _els}) -> {starttls_failure}. encode_starttls_failure({starttls_failure}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-tls">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"failure">>, _attrs, _els}. decode_starttls_proceed(__TopXMLNS, __Opts, {xmlel, <<"proceed">>, _attrs, _els}) -> {starttls_proceed}. encode_starttls_proceed({starttls_proceed}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-tls">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"proceed">>, _attrs, _els}. decode_starttls(__TopXMLNS, __Opts, {xmlel, <<"starttls">>, _attrs, _els}) -> Required = decode_starttls_els(__TopXMLNS, __Opts, _els, false), {starttls, Required}. decode_starttls_els(__TopXMLNS, __Opts, [], Required) -> Required; decode_starttls_els(__TopXMLNS, __Opts, [{xmlel, <<"required">>, _attrs, _} = _el | _els], Required) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-tls">> -> decode_starttls_els(__TopXMLNS, __Opts, _els, decode_starttls_required(<<"urn:ietf:params:xml:ns:xmpp-tls">>, __Opts, _el)); _ -> decode_starttls_els(__TopXMLNS, __Opts, _els, Required) end; decode_starttls_els(__TopXMLNS, __Opts, [_ | _els], Required) -> decode_starttls_els(__TopXMLNS, __Opts, _els, Required). encode_starttls({starttls, Required}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-tls">>, [], __TopXMLNS), _els = lists:reverse('encode_starttls_$required'(Required, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"starttls">>, _attrs, _els}. 'encode_starttls_$required'(false, __TopXMLNS, _acc) -> _acc; 'encode_starttls_$required'(Required, __TopXMLNS, _acc) -> [encode_starttls_required(Required, __TopXMLNS) | _acc]. decode_starttls_required(__TopXMLNS, __Opts, {xmlel, <<"required">>, _attrs, _els}) -> true. encode_starttls_required(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-tls">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"required">>, _attrs, _els}. decode_sasl_mechanisms(__TopXMLNS, __Opts, {xmlel, <<"mechanisms">>, _attrs, _els}) -> List = decode_sasl_mechanisms_els(__TopXMLNS, __Opts, _els, []), {sasl_mechanisms, List}. decode_sasl_mechanisms_els(__TopXMLNS, __Opts, [], List) -> lists:reverse(List); decode_sasl_mechanisms_els(__TopXMLNS, __Opts, [{xmlel, <<"mechanism">>, _attrs, _} = _el | _els], List) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_mechanisms_els(__TopXMLNS, __Opts, _els, [decode_sasl_mechanism(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el) | List]); _ -> decode_sasl_mechanisms_els(__TopXMLNS, __Opts, _els, List) end; decode_sasl_mechanisms_els(__TopXMLNS, __Opts, [_ | _els], List) -> decode_sasl_mechanisms_els(__TopXMLNS, __Opts, _els, List). encode_sasl_mechanisms({sasl_mechanisms, List}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = lists:reverse('encode_sasl_mechanisms_$list'(List, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"mechanisms">>, _attrs, _els}. 'encode_sasl_mechanisms_$list'([], __TopXMLNS, _acc) -> _acc; 'encode_sasl_mechanisms_$list'([List | _els], __TopXMLNS, _acc) -> 'encode_sasl_mechanisms_$list'(_els, __TopXMLNS, [encode_sasl_mechanism(List, __TopXMLNS) | _acc]). decode_sasl_mechanism(__TopXMLNS, __Opts, {xmlel, <<"mechanism">>, _attrs, _els}) -> Cdata = decode_sasl_mechanism_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_sasl_mechanism_els(__TopXMLNS, __Opts, [], Cdata) -> decode_sasl_mechanism_cdata(__TopXMLNS, Cdata); decode_sasl_mechanism_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_sasl_mechanism_els(__TopXMLNS, __Opts, _els, <>); decode_sasl_mechanism_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_sasl_mechanism_els(__TopXMLNS, __Opts, _els, Cdata). encode_sasl_mechanism(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = encode_sasl_mechanism_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"mechanism">>, _attrs, _els}. decode_sasl_mechanism_cdata(__TopXMLNS, <<>>) -> <<>>; decode_sasl_mechanism_cdata(__TopXMLNS, _val) -> _val. encode_sasl_mechanism_cdata(<<>>, _acc) -> _acc; encode_sasl_mechanism_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_sasl_failure(__TopXMLNS, __Opts, {xmlel, <<"failure">>, _attrs, _els}) -> {Text, Reason} = decode_sasl_failure_els(__TopXMLNS, __Opts, _els, [], undefined), {sasl_failure, Reason, Text}. decode_sasl_failure_els(__TopXMLNS, __Opts, [], Text, Reason) -> {lists:reverse(Text), Reason}; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"text">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, [decode_sasl_failure_text(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el) | Text], Reason); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"aborted">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_aborted(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"account-disabled">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_account_disabled(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"credentials-expired">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_credentials_expired(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"encryption-required">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_encryption_required(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"incorrect-encoding">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_incorrect_encoding(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"invalid-authzid">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_invalid_authzid(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"invalid-mechanism">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_invalid_mechanism(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"malformed-request">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_malformed_request(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"mechanism-too-weak">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_mechanism_too_weak(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"not-authorized">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_not_authorized(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"bad-protocol">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_bad_protocol(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [{xmlel, <<"temporary-auth-failure">>, _attrs, _} = _el | _els], Text, Reason) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-sasl">> -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, decode_sasl_failure_temporary_auth_failure(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, __Opts, _el)); _ -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason) end; decode_sasl_failure_els(__TopXMLNS, __Opts, [_ | _els], Text, Reason) -> decode_sasl_failure_els(__TopXMLNS, __Opts, _els, Text, Reason). encode_sasl_failure({sasl_failure, Reason, Text}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = lists:reverse('encode_sasl_failure_$text'(Text, __NewTopXMLNS, 'encode_sasl_failure_$reason'(Reason, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"failure">>, _attrs, _els}. 'encode_sasl_failure_$text'([], __TopXMLNS, _acc) -> _acc; 'encode_sasl_failure_$text'([Text | _els], __TopXMLNS, _acc) -> 'encode_sasl_failure_$text'(_els, __TopXMLNS, [encode_sasl_failure_text(Text, __TopXMLNS) | _acc]). 'encode_sasl_failure_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_sasl_failure_$reason'(aborted = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_aborted(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('account-disabled' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_account_disabled(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('credentials-expired' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_credentials_expired(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('encryption-required' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_encryption_required(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('incorrect-encoding' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_incorrect_encoding(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('invalid-authzid' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_invalid_authzid(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('invalid-mechanism' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_invalid_mechanism(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('malformed-request' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_malformed_request(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('mechanism-too-weak' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_mechanism_too_weak(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('not-authorized' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_not_authorized(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('bad-protocol' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_bad_protocol(Reason, __TopXMLNS) | _acc]; 'encode_sasl_failure_$reason'('temporary-auth-failure' = Reason, __TopXMLNS, _acc) -> [encode_sasl_failure_temporary_auth_failure(Reason, __TopXMLNS) | _acc]. decode_sasl_failure_temporary_auth_failure(__TopXMLNS, __Opts, {xmlel, <<"temporary-auth-failure">>, _attrs, _els}) -> 'temporary-auth-failure'. encode_sasl_failure_temporary_auth_failure('temporary-auth-failure', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"temporary-auth-failure">>, _attrs, _els}. decode_sasl_failure_bad_protocol(__TopXMLNS, __Opts, {xmlel, <<"bad-protocol">>, _attrs, _els}) -> 'bad-protocol'. encode_sasl_failure_bad_protocol('bad-protocol', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"bad-protocol">>, _attrs, _els}. decode_sasl_failure_not_authorized(__TopXMLNS, __Opts, {xmlel, <<"not-authorized">>, _attrs, _els}) -> 'not-authorized'. encode_sasl_failure_not_authorized('not-authorized', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-authorized">>, _attrs, _els}. decode_sasl_failure_mechanism_too_weak(__TopXMLNS, __Opts, {xmlel, <<"mechanism-too-weak">>, _attrs, _els}) -> 'mechanism-too-weak'. encode_sasl_failure_mechanism_too_weak('mechanism-too-weak', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"mechanism-too-weak">>, _attrs, _els}. decode_sasl_failure_malformed_request(__TopXMLNS, __Opts, {xmlel, <<"malformed-request">>, _attrs, _els}) -> 'malformed-request'. encode_sasl_failure_malformed_request('malformed-request', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"malformed-request">>, _attrs, _els}. decode_sasl_failure_invalid_mechanism(__TopXMLNS, __Opts, {xmlel, <<"invalid-mechanism">>, _attrs, _els}) -> 'invalid-mechanism'. encode_sasl_failure_invalid_mechanism('invalid-mechanism', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-mechanism">>, _attrs, _els}. decode_sasl_failure_invalid_authzid(__TopXMLNS, __Opts, {xmlel, <<"invalid-authzid">>, _attrs, _els}) -> 'invalid-authzid'. encode_sasl_failure_invalid_authzid('invalid-authzid', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"invalid-authzid">>, _attrs, _els}. decode_sasl_failure_incorrect_encoding(__TopXMLNS, __Opts, {xmlel, <<"incorrect-encoding">>, _attrs, _els}) -> 'incorrect-encoding'. encode_sasl_failure_incorrect_encoding('incorrect-encoding', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"incorrect-encoding">>, _attrs, _els}. decode_sasl_failure_encryption_required(__TopXMLNS, __Opts, {xmlel, <<"encryption-required">>, _attrs, _els}) -> 'encryption-required'. encode_sasl_failure_encryption_required('encryption-required', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"encryption-required">>, _attrs, _els}. decode_sasl_failure_credentials_expired(__TopXMLNS, __Opts, {xmlel, <<"credentials-expired">>, _attrs, _els}) -> 'credentials-expired'. encode_sasl_failure_credentials_expired('credentials-expired', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"credentials-expired">>, _attrs, _els}. decode_sasl_failure_account_disabled(__TopXMLNS, __Opts, {xmlel, <<"account-disabled">>, _attrs, _els}) -> 'account-disabled'. encode_sasl_failure_account_disabled('account-disabled', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"account-disabled">>, _attrs, _els}. decode_sasl_failure_aborted(__TopXMLNS, __Opts, {xmlel, <<"aborted">>, _attrs, _els}) -> aborted. encode_sasl_failure_aborted(aborted, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"aborted">>, _attrs, _els}. decode_sasl_failure_text(__TopXMLNS, __Opts, {xmlel, <<"text">>, _attrs, _els}) -> Data = decode_sasl_failure_text_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_sasl_failure_text_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_sasl_failure_text_els(__TopXMLNS, __Opts, [], Data) -> decode_sasl_failure_text_cdata(__TopXMLNS, Data); decode_sasl_failure_text_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_sasl_failure_text_els(__TopXMLNS, __Opts, _els, <>); decode_sasl_failure_text_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_sasl_failure_text_els(__TopXMLNS, __Opts, _els, Data). decode_sasl_failure_text_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_sasl_failure_text_attrs(__TopXMLNS, _attrs, _val); decode_sasl_failure_text_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_sasl_failure_text_attrs(__TopXMLNS, _attrs, Lang); decode_sasl_failure_text_attrs(__TopXMLNS, [], Lang) -> 'decode_sasl_failure_text_attr_xml:lang'(__TopXMLNS, Lang). encode_sasl_failure_text({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = encode_sasl_failure_text_cdata(Data, []), _attrs = 'encode_sasl_failure_text_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"text">>, _attrs, _els}. 'decode_sasl_failure_text_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_sasl_failure_text_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"text">>, __TopXMLNS}}); _res -> _res end. 'encode_sasl_failure_text_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_sasl_failure_text_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_sasl_failure_text_cdata(__TopXMLNS, <<>>) -> <<>>; decode_sasl_failure_text_cdata(__TopXMLNS, _val) -> _val. encode_sasl_failure_text_cdata(<<>>, _acc) -> _acc; encode_sasl_failure_text_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_sasl_success(__TopXMLNS, __Opts, {xmlel, <<"success">>, _attrs, _els}) -> Text = decode_sasl_success_els(__TopXMLNS, __Opts, _els, <<>>), {sasl_success, Text}. decode_sasl_success_els(__TopXMLNS, __Opts, [], Text) -> decode_sasl_success_cdata(__TopXMLNS, Text); decode_sasl_success_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Text) -> decode_sasl_success_els(__TopXMLNS, __Opts, _els, <>); decode_sasl_success_els(__TopXMLNS, __Opts, [_ | _els], Text) -> decode_sasl_success_els(__TopXMLNS, __Opts, _els, Text). encode_sasl_success({sasl_success, Text}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = encode_sasl_success_cdata(Text, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"success">>, _attrs, _els}. decode_sasl_success_cdata(__TopXMLNS, <<>>) -> <<>>; decode_sasl_success_cdata(__TopXMLNS, _val) -> case catch base64:mime_decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"success">>, __TopXMLNS}}); _res -> _res end. encode_sasl_success_cdata(<<>>, _acc) -> _acc; encode_sasl_success_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_sasl_response(__TopXMLNS, __Opts, {xmlel, <<"response">>, _attrs, _els}) -> Text = decode_sasl_response_els(__TopXMLNS, __Opts, _els, <<>>), {sasl_response, Text}. decode_sasl_response_els(__TopXMLNS, __Opts, [], Text) -> decode_sasl_response_cdata(__TopXMLNS, Text); decode_sasl_response_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Text) -> decode_sasl_response_els(__TopXMLNS, __Opts, _els, <>); decode_sasl_response_els(__TopXMLNS, __Opts, [_ | _els], Text) -> decode_sasl_response_els(__TopXMLNS, __Opts, _els, Text). encode_sasl_response({sasl_response, Text}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = encode_sasl_response_cdata(Text, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"response">>, _attrs, _els}. decode_sasl_response_cdata(__TopXMLNS, <<>>) -> <<>>; decode_sasl_response_cdata(__TopXMLNS, _val) -> case catch base64:mime_decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"response">>, __TopXMLNS}}); _res -> _res end. encode_sasl_response_cdata(<<>>, _acc) -> _acc; encode_sasl_response_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_sasl_challenge(__TopXMLNS, __Opts, {xmlel, <<"challenge">>, _attrs, _els}) -> Text = decode_sasl_challenge_els(__TopXMLNS, __Opts, _els, <<>>), {sasl_challenge, Text}. decode_sasl_challenge_els(__TopXMLNS, __Opts, [], Text) -> decode_sasl_challenge_cdata(__TopXMLNS, Text); decode_sasl_challenge_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Text) -> decode_sasl_challenge_els(__TopXMLNS, __Opts, _els, <>); decode_sasl_challenge_els(__TopXMLNS, __Opts, [_ | _els], Text) -> decode_sasl_challenge_els(__TopXMLNS, __Opts, _els, Text). encode_sasl_challenge({sasl_challenge, Text}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = encode_sasl_challenge_cdata(Text, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"challenge">>, _attrs, _els}. decode_sasl_challenge_cdata(__TopXMLNS, <<>>) -> <<>>; decode_sasl_challenge_cdata(__TopXMLNS, _val) -> case catch base64:mime_decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"challenge">>, __TopXMLNS}}); _res -> _res end. encode_sasl_challenge_cdata(<<>>, _acc) -> _acc; encode_sasl_challenge_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_sasl_abort(__TopXMLNS, __Opts, {xmlel, <<"abort">>, _attrs, _els}) -> {sasl_abort}. encode_sasl_abort({sasl_abort}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"abort">>, _attrs, _els}. decode_sasl_auth(__TopXMLNS, __Opts, {xmlel, <<"auth">>, _attrs, _els}) -> Text = decode_sasl_auth_els(__TopXMLNS, __Opts, _els, <<>>), Mechanism = decode_sasl_auth_attrs(__TopXMLNS, _attrs, undefined), {sasl_auth, Mechanism, Text}. decode_sasl_auth_els(__TopXMLNS, __Opts, [], Text) -> decode_sasl_auth_cdata(__TopXMLNS, Text); decode_sasl_auth_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Text) -> decode_sasl_auth_els(__TopXMLNS, __Opts, _els, <>); decode_sasl_auth_els(__TopXMLNS, __Opts, [_ | _els], Text) -> decode_sasl_auth_els(__TopXMLNS, __Opts, _els, Text). decode_sasl_auth_attrs(__TopXMLNS, [{<<"mechanism">>, _val} | _attrs], _Mechanism) -> decode_sasl_auth_attrs(__TopXMLNS, _attrs, _val); decode_sasl_auth_attrs(__TopXMLNS, [_ | _attrs], Mechanism) -> decode_sasl_auth_attrs(__TopXMLNS, _attrs, Mechanism); decode_sasl_auth_attrs(__TopXMLNS, [], Mechanism) -> decode_sasl_auth_attr_mechanism(__TopXMLNS, Mechanism). encode_sasl_auth({sasl_auth, Mechanism, Text}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-sasl">>, [], __TopXMLNS), _els = encode_sasl_auth_cdata(Text, []), _attrs = encode_sasl_auth_attr_mechanism(Mechanism, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"auth">>, _attrs, _els}. decode_sasl_auth_attr_mechanism(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"mechanism">>, <<"auth">>, __TopXMLNS}}); decode_sasl_auth_attr_mechanism(__TopXMLNS, _val) -> _val. encode_sasl_auth_attr_mechanism(_val, _acc) -> [{<<"mechanism">>, _val} | _acc]. decode_sasl_auth_cdata(__TopXMLNS, <<>>) -> <<>>; decode_sasl_auth_cdata(__TopXMLNS, _val) -> case catch base64:mime_decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"auth">>, __TopXMLNS}}); _res -> _res end. encode_sasl_auth_cdata(<<>>, _acc) -> _acc; encode_sasl_auth_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_bind(__TopXMLNS, __Opts, {xmlel, <<"bind">>, _attrs, _els}) -> {Jid, Resource} = decode_bind_els(__TopXMLNS, __Opts, _els, undefined, <<>>), {bind, Jid, Resource}. decode_bind_els(__TopXMLNS, __Opts, [], Jid, Resource) -> {Jid, Resource}; decode_bind_els(__TopXMLNS, __Opts, [{xmlel, <<"jid">>, _attrs, _} = _el | _els], Jid, Resource) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-bind">> -> decode_bind_els(__TopXMLNS, __Opts, _els, decode_bind_jid(<<"urn:ietf:params:xml:ns:xmpp-bind">>, __Opts, _el), Resource); _ -> decode_bind_els(__TopXMLNS, __Opts, _els, Jid, Resource) end; decode_bind_els(__TopXMLNS, __Opts, [{xmlel, <<"resource">>, _attrs, _} = _el | _els], Jid, Resource) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-bind">> -> decode_bind_els(__TopXMLNS, __Opts, _els, Jid, decode_bind_resource(<<"urn:ietf:params:xml:ns:xmpp-bind">>, __Opts, _el)); _ -> decode_bind_els(__TopXMLNS, __Opts, _els, Jid, Resource) end; decode_bind_els(__TopXMLNS, __Opts, [_ | _els], Jid, Resource) -> decode_bind_els(__TopXMLNS, __Opts, _els, Jid, Resource). encode_bind({bind, Jid, Resource}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-bind">>, [], __TopXMLNS), _els = lists:reverse('encode_bind_$jid'(Jid, __NewTopXMLNS, 'encode_bind_$resource'(Resource, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"bind">>, _attrs, _els}. 'encode_bind_$jid'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_bind_$jid'(Jid, __TopXMLNS, _acc) -> [encode_bind_jid(Jid, __TopXMLNS) | _acc]. 'encode_bind_$resource'(<<>>, __TopXMLNS, _acc) -> _acc; 'encode_bind_$resource'(Resource, __TopXMLNS, _acc) -> [encode_bind_resource(Resource, __TopXMLNS) | _acc]. decode_bind_resource(__TopXMLNS, __Opts, {xmlel, <<"resource">>, _attrs, _els}) -> Cdata = decode_bind_resource_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_bind_resource_els(__TopXMLNS, __Opts, [], Cdata) -> decode_bind_resource_cdata(__TopXMLNS, Cdata); decode_bind_resource_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_bind_resource_els(__TopXMLNS, __Opts, _els, <>); decode_bind_resource_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_bind_resource_els(__TopXMLNS, __Opts, _els, Cdata). encode_bind_resource(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-bind">>, [], __TopXMLNS), _els = encode_bind_resource_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"resource">>, _attrs, _els}. decode_bind_resource_cdata(__TopXMLNS, <<>>) -> <<>>; decode_bind_resource_cdata(__TopXMLNS, _val) -> case catch check_resource(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"resource">>, __TopXMLNS}}); _res -> _res end. encode_bind_resource_cdata(<<>>, _acc) -> _acc; encode_bind_resource_cdata(_val, _acc) -> [{xmlcdata, check_resource(_val)} | _acc]. decode_bind_jid(__TopXMLNS, __Opts, {xmlel, <<"jid">>, _attrs, _els}) -> Cdata = decode_bind_jid_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_bind_jid_els(__TopXMLNS, __Opts, [], Cdata) -> decode_bind_jid_cdata(__TopXMLNS, Cdata); decode_bind_jid_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_bind_jid_els(__TopXMLNS, __Opts, _els, <>); decode_bind_jid_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_bind_jid_els(__TopXMLNS, __Opts, _els, Cdata). encode_bind_jid(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-bind">>, [], __TopXMLNS), _els = encode_bind_jid_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"jid">>, _attrs, _els}. decode_bind_jid_cdata(__TopXMLNS, <<>>) -> undefined; decode_bind_jid_cdata(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"jid">>, __TopXMLNS}}); _res -> _res end. encode_bind_jid_cdata(undefined, _acc) -> _acc; encode_bind_jid_cdata(_val, _acc) -> [{xmlcdata, jid:encode(_val)} | _acc]. decode_error(__TopXMLNS, __Opts, {xmlel, <<"error">>, _attrs, _els}) -> {Text, Reason, __Els} = decode_error_els(__TopXMLNS, __Opts, _els, [], undefined, []), {Type, Code, By} = decode_error_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {stanza_error, Type, Code, By, Reason, Text, __Els}. decode_error_els(__TopXMLNS, __Opts, [], Text, Reason, __Els) -> {lists:reverse(Text), Reason, lists:reverse(__Els)}; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"text">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, [decode_error_text(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el) | Text], Reason, __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"bad-request">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_bad_request(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"conflict">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_conflict(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"feature-not-implemented">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_feature_not_implemented(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"forbidden">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_forbidden(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"gone">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_gone(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"internal-server-error">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_internal_server_error(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"item-not-found">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_item_not_found(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"jid-malformed">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_jid_malformed(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"not-acceptable">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_not_acceptable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"not-allowed">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_not_allowed(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"not-authorized">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_not_authorized(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"payment-required">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_payment_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"policy-violation">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_policy_violation(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"recipient-unavailable">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_recipient_unavailable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"redirect">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_redirect(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"registration-required">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_registration_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"remote-server-not-found">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_remote_server_not_found(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"remote-server-timeout">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_remote_server_timeout(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"resource-constraint">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_resource_constraint(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"service-unavailable">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_service_unavailable(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"subscription-required">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_subscription_required(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"undefined-condition">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_undefined_condition(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, <<"unexpected-request">>, _attrs, _} = _el | _els], Text, Reason, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:ietf:params:xml:ns:xmpp-stanzas">> -> decode_error_els(__TopXMLNS, __Opts, _els, Text, decode_error_unexpected_request(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, __Opts, _el), __Els); _ -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]) end; decode_error_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Text, Reason, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [_el | __Els]); Mod -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_error_els(__TopXMLNS, __Opts, [_ | _els], Text, Reason, __Els) -> decode_error_els(__TopXMLNS, __Opts, _els, Text, Reason, __Els). decode_error_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], _Type, Code, By) -> decode_error_attrs(__TopXMLNS, _attrs, _val, Code, By); decode_error_attrs(__TopXMLNS, [{<<"code">>, _val} | _attrs], Type, _Code, By) -> decode_error_attrs(__TopXMLNS, _attrs, Type, _val, By); decode_error_attrs(__TopXMLNS, [{<<"by">>, _val} | _attrs], Type, Code, _By) -> decode_error_attrs(__TopXMLNS, _attrs, Type, Code, _val); decode_error_attrs(__TopXMLNS, [_ | _attrs], Type, Code, By) -> decode_error_attrs(__TopXMLNS, _attrs, Type, Code, By); decode_error_attrs(__TopXMLNS, [], Type, Code, By) -> {decode_error_attr_type(__TopXMLNS, Type), decode_error_attr_code(__TopXMLNS, Code), decode_error_attr_by(__TopXMLNS, By)}. encode_error({stanza_error, Type, Code, By, Reason, Text, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_error_$text'(Text, __NewTopXMLNS, 'encode_error_$reason'(Reason, __NewTopXMLNS, []))), _attrs = encode_error_attr_by(By, encode_error_attr_code(Code, encode_error_attr_type(Type, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"error">>, _attrs, _els}. 'encode_error_$text'([], __TopXMLNS, _acc) -> _acc; 'encode_error_$text'([Text | _els], __TopXMLNS, _acc) -> 'encode_error_$text'(_els, __TopXMLNS, [encode_error_text(Text, __TopXMLNS) | _acc]). 'encode_error_$reason'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_error_$reason'('bad-request' = Reason, __TopXMLNS, _acc) -> [encode_error_bad_request(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'(conflict = Reason, __TopXMLNS, _acc) -> [encode_error_conflict(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('feature-not-implemented' = Reason, __TopXMLNS, _acc) -> [encode_error_feature_not_implemented(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'(forbidden = Reason, __TopXMLNS, _acc) -> [encode_error_forbidden(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'({gone, _} = Reason, __TopXMLNS, _acc) -> [encode_error_gone(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('internal-server-error' = Reason, __TopXMLNS, _acc) -> [encode_error_internal_server_error(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('item-not-found' = Reason, __TopXMLNS, _acc) -> [encode_error_item_not_found(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('jid-malformed' = Reason, __TopXMLNS, _acc) -> [encode_error_jid_malformed(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('not-acceptable' = Reason, __TopXMLNS, _acc) -> [encode_error_not_acceptable(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('not-allowed' = Reason, __TopXMLNS, _acc) -> [encode_error_not_allowed(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('not-authorized' = Reason, __TopXMLNS, _acc) -> [encode_error_not_authorized(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('payment-required' = Reason, __TopXMLNS, _acc) -> [encode_error_payment_required(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('policy-violation' = Reason, __TopXMLNS, _acc) -> [encode_error_policy_violation(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('recipient-unavailable' = Reason, __TopXMLNS, _acc) -> [encode_error_recipient_unavailable(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'({redirect, _} = Reason, __TopXMLNS, _acc) -> [encode_error_redirect(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('registration-required' = Reason, __TopXMLNS, _acc) -> [encode_error_registration_required(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('remote-server-not-found' = Reason, __TopXMLNS, _acc) -> [encode_error_remote_server_not_found(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('remote-server-timeout' = Reason, __TopXMLNS, _acc) -> [encode_error_remote_server_timeout(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('resource-constraint' = Reason, __TopXMLNS, _acc) -> [encode_error_resource_constraint(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('service-unavailable' = Reason, __TopXMLNS, _acc) -> [encode_error_service_unavailable(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('subscription-required' = Reason, __TopXMLNS, _acc) -> [encode_error_subscription_required(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('undefined-condition' = Reason, __TopXMLNS, _acc) -> [encode_error_undefined_condition(Reason, __TopXMLNS) | _acc]; 'encode_error_$reason'('unexpected-request' = Reason, __TopXMLNS, _acc) -> [encode_error_unexpected_request(Reason, __TopXMLNS) | _acc]. decode_error_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"error">>, __TopXMLNS}}); decode_error_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [auth, cancel, continue, modify, wait]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"error">>, __TopXMLNS}}); _res -> _res end. encode_error_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_error_attr_code(__TopXMLNS, undefined) -> undefined; decode_error_attr_code(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"code">>, <<"error">>, __TopXMLNS}}); _res -> _res end. encode_error_attr_code(undefined, _acc) -> _acc; encode_error_attr_code(_val, _acc) -> [{<<"code">>, enc_int(_val)} | _acc]. decode_error_attr_by(__TopXMLNS, undefined) -> undefined; decode_error_attr_by(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"by">>, <<"error">>, __TopXMLNS}}); _res -> _res end. encode_error_attr_by(undefined, _acc) -> _acc; encode_error_attr_by(_val, _acc) -> [{<<"by">>, jid:encode(_val)} | _acc]. decode_error_text(__TopXMLNS, __Opts, {xmlel, <<"text">>, _attrs, _els}) -> Data = decode_error_text_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_error_text_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_error_text_els(__TopXMLNS, __Opts, [], Data) -> decode_error_text_cdata(__TopXMLNS, Data); decode_error_text_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_error_text_els(__TopXMLNS, __Opts, _els, <>); decode_error_text_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_error_text_els(__TopXMLNS, __Opts, _els, Data). decode_error_text_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_error_text_attrs(__TopXMLNS, _attrs, _val); decode_error_text_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_error_text_attrs(__TopXMLNS, _attrs, Lang); decode_error_text_attrs(__TopXMLNS, [], Lang) -> 'decode_error_text_attr_xml:lang'(__TopXMLNS, Lang). encode_error_text({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = encode_error_text_cdata(Data, []), _attrs = 'encode_error_text_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"text">>, _attrs, _els}. 'decode_error_text_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_error_text_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"text">>, __TopXMLNS}}); _res -> _res end. 'encode_error_text_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_error_text_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_error_text_cdata(__TopXMLNS, <<>>) -> <<>>; decode_error_text_cdata(__TopXMLNS, _val) -> _val. encode_error_text_cdata(<<>>, _acc) -> _acc; encode_error_text_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_error_unexpected_request(__TopXMLNS, __Opts, {xmlel, <<"unexpected-request">>, _attrs, _els}) -> 'unexpected-request'. encode_error_unexpected_request('unexpected-request', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"unexpected-request">>, _attrs, _els}. decode_error_undefined_condition(__TopXMLNS, __Opts, {xmlel, <<"undefined-condition">>, _attrs, _els}) -> 'undefined-condition'. encode_error_undefined_condition('undefined-condition', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"undefined-condition">>, _attrs, _els}. decode_error_subscription_required(__TopXMLNS, __Opts, {xmlel, <<"subscription-required">>, _attrs, _els}) -> 'subscription-required'. encode_error_subscription_required('subscription-required', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"subscription-required">>, _attrs, _els}. decode_error_service_unavailable(__TopXMLNS, __Opts, {xmlel, <<"service-unavailable">>, _attrs, _els}) -> 'service-unavailable'. encode_error_service_unavailable('service-unavailable', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"service-unavailable">>, _attrs, _els}. decode_error_resource_constraint(__TopXMLNS, __Opts, {xmlel, <<"resource-constraint">>, _attrs, _els}) -> 'resource-constraint'. encode_error_resource_constraint('resource-constraint', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"resource-constraint">>, _attrs, _els}. decode_error_remote_server_timeout(__TopXMLNS, __Opts, {xmlel, <<"remote-server-timeout">>, _attrs, _els}) -> 'remote-server-timeout'. encode_error_remote_server_timeout('remote-server-timeout', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"remote-server-timeout">>, _attrs, _els}. decode_error_remote_server_not_found(__TopXMLNS, __Opts, {xmlel, <<"remote-server-not-found">>, _attrs, _els}) -> 'remote-server-not-found'. encode_error_remote_server_not_found('remote-server-not-found', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"remote-server-not-found">>, _attrs, _els}. decode_error_registration_required(__TopXMLNS, __Opts, {xmlel, <<"registration-required">>, _attrs, _els}) -> 'registration-required'. encode_error_registration_required('registration-required', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"registration-required">>, _attrs, _els}. decode_error_redirect(__TopXMLNS, __Opts, {xmlel, <<"redirect">>, _attrs, _els}) -> Uri = decode_error_redirect_els(__TopXMLNS, __Opts, _els, <<>>), {redirect, Uri}. decode_error_redirect_els(__TopXMLNS, __Opts, [], Uri) -> decode_error_redirect_cdata(__TopXMLNS, Uri); decode_error_redirect_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Uri) -> decode_error_redirect_els(__TopXMLNS, __Opts, _els, <>); decode_error_redirect_els(__TopXMLNS, __Opts, [_ | _els], Uri) -> decode_error_redirect_els(__TopXMLNS, __Opts, _els, Uri). encode_error_redirect({redirect, Uri}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = encode_error_redirect_cdata(Uri, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"redirect">>, _attrs, _els}. decode_error_redirect_cdata(__TopXMLNS, <<>>) -> <<>>; decode_error_redirect_cdata(__TopXMLNS, _val) -> _val. encode_error_redirect_cdata(<<>>, _acc) -> _acc; encode_error_redirect_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_error_recipient_unavailable(__TopXMLNS, __Opts, {xmlel, <<"recipient-unavailable">>, _attrs, _els}) -> 'recipient-unavailable'. encode_error_recipient_unavailable('recipient-unavailable', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"recipient-unavailable">>, _attrs, _els}. decode_error_policy_violation(__TopXMLNS, __Opts, {xmlel, <<"policy-violation">>, _attrs, _els}) -> 'policy-violation'. encode_error_policy_violation('policy-violation', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"policy-violation">>, _attrs, _els}. decode_error_payment_required(__TopXMLNS, __Opts, {xmlel, <<"payment-required">>, _attrs, _els}) -> 'payment-required'. encode_error_payment_required('payment-required', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"payment-required">>, _attrs, _els}. decode_error_not_authorized(__TopXMLNS, __Opts, {xmlel, <<"not-authorized">>, _attrs, _els}) -> 'not-authorized'. encode_error_not_authorized('not-authorized', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-authorized">>, _attrs, _els}. decode_error_not_allowed(__TopXMLNS, __Opts, {xmlel, <<"not-allowed">>, _attrs, _els}) -> 'not-allowed'. encode_error_not_allowed('not-allowed', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-allowed">>, _attrs, _els}. decode_error_not_acceptable(__TopXMLNS, __Opts, {xmlel, <<"not-acceptable">>, _attrs, _els}) -> 'not-acceptable'. encode_error_not_acceptable('not-acceptable', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"not-acceptable">>, _attrs, _els}. decode_error_jid_malformed(__TopXMLNS, __Opts, {xmlel, <<"jid-malformed">>, _attrs, _els}) -> 'jid-malformed'. encode_error_jid_malformed('jid-malformed', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"jid-malformed">>, _attrs, _els}. decode_error_item_not_found(__TopXMLNS, __Opts, {xmlel, <<"item-not-found">>, _attrs, _els}) -> 'item-not-found'. encode_error_item_not_found('item-not-found', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"item-not-found">>, _attrs, _els}. decode_error_internal_server_error(__TopXMLNS, __Opts, {xmlel, <<"internal-server-error">>, _attrs, _els}) -> 'internal-server-error'. encode_error_internal_server_error('internal-server-error', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"internal-server-error">>, _attrs, _els}. decode_error_gone(__TopXMLNS, __Opts, {xmlel, <<"gone">>, _attrs, _els}) -> Uri = decode_error_gone_els(__TopXMLNS, __Opts, _els, <<>>), {gone, Uri}. decode_error_gone_els(__TopXMLNS, __Opts, [], Uri) -> decode_error_gone_cdata(__TopXMLNS, Uri); decode_error_gone_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Uri) -> decode_error_gone_els(__TopXMLNS, __Opts, _els, <>); decode_error_gone_els(__TopXMLNS, __Opts, [_ | _els], Uri) -> decode_error_gone_els(__TopXMLNS, __Opts, _els, Uri). encode_error_gone({gone, Uri}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = encode_error_gone_cdata(Uri, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"gone">>, _attrs, _els}. decode_error_gone_cdata(__TopXMLNS, <<>>) -> <<>>; decode_error_gone_cdata(__TopXMLNS, _val) -> _val. encode_error_gone_cdata(<<>>, _acc) -> _acc; encode_error_gone_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_error_forbidden(__TopXMLNS, __Opts, {xmlel, <<"forbidden">>, _attrs, _els}) -> forbidden. encode_error_forbidden(forbidden, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"forbidden">>, _attrs, _els}. decode_error_feature_not_implemented(__TopXMLNS, __Opts, {xmlel, <<"feature-not-implemented">>, _attrs, _els}) -> 'feature-not-implemented'. encode_error_feature_not_implemented('feature-not-implemented', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"feature-not-implemented">>, _attrs, _els}. decode_error_conflict(__TopXMLNS, __Opts, {xmlel, <<"conflict">>, _attrs, _els}) -> conflict. encode_error_conflict(conflict, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"conflict">>, _attrs, _els}. decode_error_bad_request(__TopXMLNS, __Opts, {xmlel, <<"bad-request">>, _attrs, _els}) -> 'bad-request'. encode_error_bad_request('bad-request', __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:ietf:params:xml:ns:xmpp-stanzas">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"bad-request">>, _attrs, _els}. decode_presence(__TopXMLNS, __Opts, {xmlel, <<"presence">>, _attrs, _els}) -> {Status, Show, Priority, __Els} = decode_presence_els(__TopXMLNS, __Opts, _els, [], undefined, undefined, []), {Id, Type, From, To, Lang} = decode_presence_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {presence, Id, Type, Lang, From, To, Show, Status, Priority, __Els, #{}}. decode_presence_els(__TopXMLNS, __Opts, [], Status, Show, Priority, __Els) -> {lists:reverse(Status), Show, Priority, lists:reverse(__Els)}; decode_presence_els(__TopXMLNS, __Opts, [{xmlel, <<"show">>, _attrs, _} = _el | _els], Status, Show, Priority, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:client">> -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, decode_presence_show(<<"jabber:client">>, __Opts, _el), Priority, __Els); <<"jabber:server">> -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, decode_presence_show(<<"jabber:server">>, __Opts, _el), Priority, __Els); <<"jabber:component:accept">> -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, decode_presence_show(<<"jabber:component:accept">>, __Opts, _el), Priority, __Els); _ -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, Priority, [_el | __Els]) end; decode_presence_els(__TopXMLNS, __Opts, [{xmlel, <<"status">>, _attrs, _} = _el | _els], Status, Show, Priority, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:client">> -> decode_presence_els(__TopXMLNS, __Opts, _els, [decode_presence_status(<<"jabber:client">>, __Opts, _el) | Status], Show, Priority, __Els); <<"jabber:server">> -> decode_presence_els(__TopXMLNS, __Opts, _els, [decode_presence_status(<<"jabber:server">>, __Opts, _el) | Status], Show, Priority, __Els); <<"jabber:component:accept">> -> decode_presence_els(__TopXMLNS, __Opts, _els, [decode_presence_status(<<"jabber:component:accept">>, __Opts, _el) | Status], Show, Priority, __Els); _ -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, Priority, [_el | __Els]) end; decode_presence_els(__TopXMLNS, __Opts, [{xmlel, <<"priority">>, _attrs, _} = _el | _els], Status, Show, Priority, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:client">> -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, decode_presence_priority(<<"jabber:client">>, __Opts, _el), __Els); <<"jabber:server">> -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, decode_presence_priority(<<"jabber:server">>, __Opts, _el), __Els); <<"jabber:component:accept">> -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, decode_presence_priority(<<"jabber:component:accept">>, __Opts, _el), __Els); _ -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, Priority, [_el | __Els]) end; decode_presence_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Status, Show, Priority, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, Priority, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, Priority, [_el | __Els]); Mod -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, Priority, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_presence_els(__TopXMLNS, __Opts, [_ | _els], Status, Show, Priority, __Els) -> decode_presence_els(__TopXMLNS, __Opts, _els, Status, Show, Priority, __Els). decode_presence_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, Type, From, To, Lang) -> decode_presence_attrs(__TopXMLNS, _attrs, _val, Type, From, To, Lang); decode_presence_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Id, _Type, From, To, Lang) -> decode_presence_attrs(__TopXMLNS, _attrs, Id, _val, From, To, Lang); decode_presence_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], Id, Type, _From, To, Lang) -> decode_presence_attrs(__TopXMLNS, _attrs, Id, Type, _val, To, Lang); decode_presence_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], Id, Type, From, _To, Lang) -> decode_presence_attrs(__TopXMLNS, _attrs, Id, Type, From, _val, Lang); decode_presence_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], Id, Type, From, To, _Lang) -> decode_presence_attrs(__TopXMLNS, _attrs, Id, Type, From, To, _val); decode_presence_attrs(__TopXMLNS, [_ | _attrs], Id, Type, From, To, Lang) -> decode_presence_attrs(__TopXMLNS, _attrs, Id, Type, From, To, Lang); decode_presence_attrs(__TopXMLNS, [], Id, Type, From, To, Lang) -> {decode_presence_attr_id(__TopXMLNS, Id), decode_presence_attr_type(__TopXMLNS, Type), decode_presence_attr_from(__TopXMLNS, From), decode_presence_attr_to(__TopXMLNS, To), 'decode_presence_attr_xml:lang'(__TopXMLNS, Lang)}. encode_presence({presence, Id, Type, Lang, From, To, Show, Status, Priority, __Els, _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_presence_$status'(Status, __NewTopXMLNS, 'encode_presence_$show'(Show, __NewTopXMLNS, 'encode_presence_$priority'(Priority, __NewTopXMLNS, [])))), _attrs = 'encode_presence_attr_xml:lang'(Lang, encode_presence_attr_to(To, encode_presence_attr_from(From, encode_presence_attr_type(Type, encode_presence_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"presence">>, _attrs, _els}. 'encode_presence_$status'([], __TopXMLNS, _acc) -> _acc; 'encode_presence_$status'([Status | _els], __TopXMLNS, _acc) -> 'encode_presence_$status'(_els, __TopXMLNS, [encode_presence_status(Status, __TopXMLNS) | _acc]). 'encode_presence_$show'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_presence_$show'(Show, __TopXMLNS, _acc) -> [encode_presence_show(Show, __TopXMLNS) | _acc]. 'encode_presence_$priority'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_presence_$priority'(Priority, __TopXMLNS, _acc) -> [encode_presence_priority(Priority, __TopXMLNS) | _acc]. decode_presence_attr_id(__TopXMLNS, undefined) -> <<>>; decode_presence_attr_id(__TopXMLNS, _val) -> _val. encode_presence_attr_id(<<>>, _acc) -> _acc; encode_presence_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_presence_attr_type(__TopXMLNS, undefined) -> available; decode_presence_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [unavailable, subscribe, subscribed, unsubscribe, unsubscribed, available, probe, error]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"presence">>, __TopXMLNS}}); _res -> _res end. encode_presence_attr_type(available, _acc) -> _acc; encode_presence_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_presence_attr_from(__TopXMLNS, undefined) -> undefined; decode_presence_attr_from(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"presence">>, __TopXMLNS}}); _res -> _res end. encode_presence_attr_from(undefined, _acc) -> _acc; encode_presence_attr_from(_val, _acc) -> [{<<"from">>, jid:encode(_val)} | _acc]. decode_presence_attr_to(__TopXMLNS, undefined) -> undefined; decode_presence_attr_to(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"presence">>, __TopXMLNS}}); _res -> _res end. encode_presence_attr_to(undefined, _acc) -> _acc; encode_presence_attr_to(_val, _acc) -> [{<<"to">>, jid:encode(_val)} | _acc]. 'decode_presence_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_presence_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"presence">>, __TopXMLNS}}); _res -> _res end. 'encode_presence_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_presence_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_presence_priority(__TopXMLNS, __Opts, {xmlel, <<"priority">>, _attrs, _els}) -> Cdata = decode_presence_priority_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_presence_priority_els(__TopXMLNS, __Opts, [], Cdata) -> decode_presence_priority_cdata(__TopXMLNS, Cdata); decode_presence_priority_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_presence_priority_els(__TopXMLNS, __Opts, _els, <>); decode_presence_priority_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_presence_priority_els(__TopXMLNS, __Opts, _els, Cdata). encode_presence_priority(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = encode_presence_priority_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"priority">>, _attrs, _els}. decode_presence_priority_cdata(__TopXMLNS, <<>>) -> undefined; decode_presence_priority_cdata(__TopXMLNS, _val) -> case catch dec_int(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"priority">>, __TopXMLNS}}); _res -> _res end. encode_presence_priority_cdata(undefined, _acc) -> _acc; encode_presence_priority_cdata(_val, _acc) -> [{xmlcdata, enc_int(_val)} | _acc]. decode_presence_status(__TopXMLNS, __Opts, {xmlel, <<"status">>, _attrs, _els}) -> Data = decode_presence_status_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_presence_status_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_presence_status_els(__TopXMLNS, __Opts, [], Data) -> decode_presence_status_cdata(__TopXMLNS, Data); decode_presence_status_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_presence_status_els(__TopXMLNS, __Opts, _els, <>); decode_presence_status_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_presence_status_els(__TopXMLNS, __Opts, _els, Data). decode_presence_status_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_presence_status_attrs(__TopXMLNS, _attrs, _val); decode_presence_status_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_presence_status_attrs(__TopXMLNS, _attrs, Lang); decode_presence_status_attrs(__TopXMLNS, [], Lang) -> 'decode_presence_status_attr_xml:lang'(__TopXMLNS, Lang). encode_presence_status({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = encode_presence_status_cdata(Data, []), _attrs = 'encode_presence_status_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"status">>, _attrs, _els}. 'decode_presence_status_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_presence_status_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"status">>, __TopXMLNS}}); _res -> _res end. 'encode_presence_status_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_presence_status_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_presence_status_cdata(__TopXMLNS, <<>>) -> <<>>; decode_presence_status_cdata(__TopXMLNS, _val) -> _val. encode_presence_status_cdata(<<>>, _acc) -> _acc; encode_presence_status_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_presence_show(__TopXMLNS, __Opts, {xmlel, <<"show">>, _attrs, _els}) -> Cdata = decode_presence_show_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_presence_show_els(__TopXMLNS, __Opts, [], Cdata) -> decode_presence_show_cdata(__TopXMLNS, Cdata); decode_presence_show_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_presence_show_els(__TopXMLNS, __Opts, _els, <>); decode_presence_show_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_presence_show_els(__TopXMLNS, __Opts, _els, Cdata). encode_presence_show(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = encode_presence_show_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"show">>, _attrs, _els}. decode_presence_show_cdata(__TopXMLNS, <<>>) -> undefined; decode_presence_show_cdata(__TopXMLNS, _val) -> case catch dec_enum(_val, [away, chat, dnd, xa]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"show">>, __TopXMLNS}}); _res -> _res end. encode_presence_show_cdata(undefined, _acc) -> _acc; encode_presence_show_cdata(_val, _acc) -> [{xmlcdata, enc_enum(_val)} | _acc]. decode_message(__TopXMLNS, __Opts, {xmlel, <<"message">>, _attrs, _els}) -> {Thread, Subject, Body, __Els} = decode_message_els(__TopXMLNS, __Opts, _els, undefined, [], [], []), {Id, Type, From, To, Lang} = decode_message_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {message, Id, Type, Lang, From, To, Subject, Body, Thread, __Els, #{}}. decode_message_els(__TopXMLNS, __Opts, [], Thread, Subject, Body, __Els) -> {Thread, lists:reverse(Subject), lists:reverse(Body), lists:reverse(__Els)}; decode_message_els(__TopXMLNS, __Opts, [{xmlel, <<"subject">>, _attrs, _} = _el | _els], Thread, Subject, Body, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:client">> -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, [decode_message_subject(<<"jabber:client">>, __Opts, _el) | Subject], Body, __Els); <<"jabber:server">> -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, [decode_message_subject(<<"jabber:server">>, __Opts, _el) | Subject], Body, __Els); <<"jabber:component:accept">> -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, [decode_message_subject(<<"jabber:component:accept">>, __Opts, _el) | Subject], Body, __Els); _ -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, Body, [_el | __Els]) end; decode_message_els(__TopXMLNS, __Opts, [{xmlel, <<"thread">>, _attrs, _} = _el | _els], Thread, Subject, Body, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:client">> -> decode_message_els(__TopXMLNS, __Opts, _els, decode_message_thread(<<"jabber:client">>, __Opts, _el), Subject, Body, __Els); <<"jabber:server">> -> decode_message_els(__TopXMLNS, __Opts, _els, decode_message_thread(<<"jabber:server">>, __Opts, _el), Subject, Body, __Els); <<"jabber:component:accept">> -> decode_message_els(__TopXMLNS, __Opts, _els, decode_message_thread(<<"jabber:component:accept">>, __Opts, _el), Subject, Body, __Els); _ -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, Body, [_el | __Els]) end; decode_message_els(__TopXMLNS, __Opts, [{xmlel, <<"body">>, _attrs, _} = _el | _els], Thread, Subject, Body, __Els) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:client">> -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, [decode_message_body(<<"jabber:client">>, __Opts, _el) | Body], __Els); <<"jabber:server">> -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, [decode_message_body(<<"jabber:server">>, __Opts, _el) | Body], __Els); <<"jabber:component:accept">> -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, [decode_message_body(<<"jabber:component:accept">>, __Opts, _el) | Body], __Els); _ -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, Body, [_el | __Els]) end; decode_message_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], Thread, Subject, Body, __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, Body, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, Body, [_el | __Els]); Mod -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, Body, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_message_els(__TopXMLNS, __Opts, [_ | _els], Thread, Subject, Body, __Els) -> decode_message_els(__TopXMLNS, __Opts, _els, Thread, Subject, Body, __Els). decode_message_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, Type, From, To, Lang) -> decode_message_attrs(__TopXMLNS, _attrs, _val, Type, From, To, Lang); decode_message_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Id, _Type, From, To, Lang) -> decode_message_attrs(__TopXMLNS, _attrs, Id, _val, From, To, Lang); decode_message_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], Id, Type, _From, To, Lang) -> decode_message_attrs(__TopXMLNS, _attrs, Id, Type, _val, To, Lang); decode_message_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], Id, Type, From, _To, Lang) -> decode_message_attrs(__TopXMLNS, _attrs, Id, Type, From, _val, Lang); decode_message_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], Id, Type, From, To, _Lang) -> decode_message_attrs(__TopXMLNS, _attrs, Id, Type, From, To, _val); decode_message_attrs(__TopXMLNS, [_ | _attrs], Id, Type, From, To, Lang) -> decode_message_attrs(__TopXMLNS, _attrs, Id, Type, From, To, Lang); decode_message_attrs(__TopXMLNS, [], Id, Type, From, To, Lang) -> {decode_message_attr_id(__TopXMLNS, Id), decode_message_attr_type(__TopXMLNS, Type), decode_message_attr_from(__TopXMLNS, From), decode_message_attr_to(__TopXMLNS, To), 'decode_message_attr_xml:lang'(__TopXMLNS, Lang)}. encode_message({message, Id, Type, Lang, From, To, Subject, Body, Thread, __Els, _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els] ++ lists:reverse('encode_message_$thread'(Thread, __NewTopXMLNS, 'encode_message_$subject'(Subject, __NewTopXMLNS, 'encode_message_$body'(Body, __NewTopXMLNS, [])))), _attrs = 'encode_message_attr_xml:lang'(Lang, encode_message_attr_to(To, encode_message_attr_from(From, encode_message_attr_type(Type, encode_message_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"message">>, _attrs, _els}. 'encode_message_$thread'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_message_$thread'(Thread, __TopXMLNS, _acc) -> [encode_message_thread(Thread, __TopXMLNS) | _acc]. 'encode_message_$subject'([], __TopXMLNS, _acc) -> _acc; 'encode_message_$subject'([Subject | _els], __TopXMLNS, _acc) -> 'encode_message_$subject'(_els, __TopXMLNS, [encode_message_subject(Subject, __TopXMLNS) | _acc]). 'encode_message_$body'([], __TopXMLNS, _acc) -> _acc; 'encode_message_$body'([Body | _els], __TopXMLNS, _acc) -> 'encode_message_$body'(_els, __TopXMLNS, [encode_message_body(Body, __TopXMLNS) | _acc]). decode_message_attr_id(__TopXMLNS, undefined) -> <<>>; decode_message_attr_id(__TopXMLNS, _val) -> _val. encode_message_attr_id(<<>>, _acc) -> _acc; encode_message_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_message_attr_type(__TopXMLNS, undefined) -> normal; decode_message_attr_type(__TopXMLNS, _val) -> case catch dec_message_type(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"message">>, __TopXMLNS}}); _res -> _res end. encode_message_attr_type(normal, _acc) -> _acc; encode_message_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_message_attr_from(__TopXMLNS, undefined) -> undefined; decode_message_attr_from(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"message">>, __TopXMLNS}}); _res -> _res end. encode_message_attr_from(undefined, _acc) -> _acc; encode_message_attr_from(_val, _acc) -> [{<<"from">>, jid:encode(_val)} | _acc]. decode_message_attr_to(__TopXMLNS, undefined) -> undefined; decode_message_attr_to(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"message">>, __TopXMLNS}}); _res -> _res end. encode_message_attr_to(undefined, _acc) -> _acc; encode_message_attr_to(_val, _acc) -> [{<<"to">>, jid:encode(_val)} | _acc]. 'decode_message_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_message_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"message">>, __TopXMLNS}}); _res -> _res end. 'encode_message_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_message_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_message_thread(__TopXMLNS, __Opts, {xmlel, <<"thread">>, _attrs, _els}) -> Data = decode_message_thread_els(__TopXMLNS, __Opts, _els, <<>>), Parent = decode_message_thread_attrs(__TopXMLNS, _attrs, undefined), {message_thread, Parent, Data}. decode_message_thread_els(__TopXMLNS, __Opts, [], Data) -> decode_message_thread_cdata(__TopXMLNS, Data); decode_message_thread_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_message_thread_els(__TopXMLNS, __Opts, _els, <>); decode_message_thread_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_message_thread_els(__TopXMLNS, __Opts, _els, Data). decode_message_thread_attrs(__TopXMLNS, [{<<"parent">>, _val} | _attrs], _Parent) -> decode_message_thread_attrs(__TopXMLNS, _attrs, _val); decode_message_thread_attrs(__TopXMLNS, [_ | _attrs], Parent) -> decode_message_thread_attrs(__TopXMLNS, _attrs, Parent); decode_message_thread_attrs(__TopXMLNS, [], Parent) -> decode_message_thread_attr_parent(__TopXMLNS, Parent). encode_message_thread({message_thread, Parent, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = encode_message_thread_cdata(Data, []), _attrs = encode_message_thread_attr_parent(Parent, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"thread">>, _attrs, _els}. decode_message_thread_attr_parent(__TopXMLNS, undefined) -> <<>>; decode_message_thread_attr_parent(__TopXMLNS, _val) -> _val. encode_message_thread_attr_parent(<<>>, _acc) -> _acc; encode_message_thread_attr_parent(_val, _acc) -> [{<<"parent">>, _val} | _acc]. decode_message_thread_cdata(__TopXMLNS, <<>>) -> <<>>; decode_message_thread_cdata(__TopXMLNS, _val) -> _val. encode_message_thread_cdata(<<>>, _acc) -> _acc; encode_message_thread_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_message_body(__TopXMLNS, __Opts, {xmlel, <<"body">>, _attrs, _els}) -> Data = decode_message_body_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_message_body_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_message_body_els(__TopXMLNS, __Opts, [], Data) -> decode_message_body_cdata(__TopXMLNS, Data); decode_message_body_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_message_body_els(__TopXMLNS, __Opts, _els, <>); decode_message_body_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_message_body_els(__TopXMLNS, __Opts, _els, Data). decode_message_body_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_message_body_attrs(__TopXMLNS, _attrs, _val); decode_message_body_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_message_body_attrs(__TopXMLNS, _attrs, Lang); decode_message_body_attrs(__TopXMLNS, [], Lang) -> 'decode_message_body_attr_xml:lang'(__TopXMLNS, Lang). encode_message_body({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = encode_message_body_cdata(Data, []), _attrs = 'encode_message_body_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"body">>, _attrs, _els}. 'decode_message_body_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_message_body_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"body">>, __TopXMLNS}}); _res -> _res end. 'encode_message_body_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_message_body_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_message_body_cdata(__TopXMLNS, <<>>) -> <<>>; decode_message_body_cdata(__TopXMLNS, _val) -> _val. encode_message_body_cdata(<<>>, _acc) -> _acc; encode_message_body_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_message_subject(__TopXMLNS, __Opts, {xmlel, <<"subject">>, _attrs, _els}) -> Data = decode_message_subject_els(__TopXMLNS, __Opts, _els, <<>>), Lang = decode_message_subject_attrs(__TopXMLNS, _attrs, undefined), {text, Lang, Data}. decode_message_subject_els(__TopXMLNS, __Opts, [], Data) -> decode_message_subject_cdata(__TopXMLNS, Data); decode_message_subject_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_message_subject_els(__TopXMLNS, __Opts, _els, <>); decode_message_subject_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_message_subject_els(__TopXMLNS, __Opts, _els, Data). decode_message_subject_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], _Lang) -> decode_message_subject_attrs(__TopXMLNS, _attrs, _val); decode_message_subject_attrs(__TopXMLNS, [_ | _attrs], Lang) -> decode_message_subject_attrs(__TopXMLNS, _attrs, Lang); decode_message_subject_attrs(__TopXMLNS, [], Lang) -> 'decode_message_subject_attr_xml:lang'(__TopXMLNS, Lang). encode_message_subject({text, Lang, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = encode_message_subject_cdata(Data, []), _attrs = 'encode_message_subject_attr_xml:lang'(Lang, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"subject">>, _attrs, _els}. 'decode_message_subject_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_message_subject_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"subject">>, __TopXMLNS}}); _res -> _res end. 'encode_message_subject_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_message_subject_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. decode_message_subject_cdata(__TopXMLNS, <<>>) -> <<>>; decode_message_subject_cdata(__TopXMLNS, _val) -> _val. encode_message_subject_cdata(<<>>, _acc) -> _acc; encode_message_subject_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_iq(__TopXMLNS, __Opts, {xmlel, <<"iq">>, _attrs, _els}) -> __Els = decode_iq_els(__TopXMLNS, __Opts, _els, []), {Id, Type, From, To, Lang} = decode_iq_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined, undefined), {iq, Id, Type, Lang, From, To, __Els, #{}}. decode_iq_els(__TopXMLNS, __Opts, [], __Els) -> lists:reverse(__Els); decode_iq_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_iq_els(__TopXMLNS, __Opts, _els, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_iq_els(__TopXMLNS, __Opts, _els, [_el | __Els]); Mod -> decode_iq_els(__TopXMLNS, __Opts, _els, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_iq_els(__TopXMLNS, __Opts, [_ | _els], __Els) -> decode_iq_els(__TopXMLNS, __Opts, _els, __Els). decode_iq_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, Type, From, To, Lang) -> decode_iq_attrs(__TopXMLNS, _attrs, _val, Type, From, To, Lang); decode_iq_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Id, _Type, From, To, Lang) -> decode_iq_attrs(__TopXMLNS, _attrs, Id, _val, From, To, Lang); decode_iq_attrs(__TopXMLNS, [{<<"from">>, _val} | _attrs], Id, Type, _From, To, Lang) -> decode_iq_attrs(__TopXMLNS, _attrs, Id, Type, _val, To, Lang); decode_iq_attrs(__TopXMLNS, [{<<"to">>, _val} | _attrs], Id, Type, From, _To, Lang) -> decode_iq_attrs(__TopXMLNS, _attrs, Id, Type, From, _val, Lang); decode_iq_attrs(__TopXMLNS, [{<<"xml:lang">>, _val} | _attrs], Id, Type, From, To, _Lang) -> decode_iq_attrs(__TopXMLNS, _attrs, Id, Type, From, To, _val); decode_iq_attrs(__TopXMLNS, [_ | _attrs], Id, Type, From, To, Lang) -> decode_iq_attrs(__TopXMLNS, _attrs, Id, Type, From, To, Lang); decode_iq_attrs(__TopXMLNS, [], Id, Type, From, To, Lang) -> {decode_iq_attr_id(__TopXMLNS, Id), decode_iq_attr_type(__TopXMLNS, Type), decode_iq_attr_from(__TopXMLNS, From), decode_iq_attr_to(__TopXMLNS, To), 'decode_iq_attr_xml:lang'(__TopXMLNS, Lang)}. encode_iq({iq, Id, Type, Lang, From, To, __Els, _}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"jabber:client">>, <<"jabber:server">>, <<"jabber:component:accept">>], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els], _attrs = 'encode_iq_attr_xml:lang'(Lang, encode_iq_attr_to(To, encode_iq_attr_from(From, encode_iq_attr_type(Type, encode_iq_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))))), {xmlel, <<"iq">>, _attrs, _els}. decode_iq_attr_id(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"id">>, <<"iq">>, __TopXMLNS}}); decode_iq_attr_id(__TopXMLNS, _val) -> _val. encode_iq_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_iq_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"iq">>, __TopXMLNS}}); decode_iq_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [get, set, result, error]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"iq">>, __TopXMLNS}}); _res -> _res end. encode_iq_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. decode_iq_attr_from(__TopXMLNS, undefined) -> undefined; decode_iq_attr_from(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"from">>, <<"iq">>, __TopXMLNS}}); _res -> _res end. encode_iq_attr_from(undefined, _acc) -> _acc; encode_iq_attr_from(_val, _acc) -> [{<<"from">>, jid:encode(_val)} | _acc]. decode_iq_attr_to(__TopXMLNS, undefined) -> undefined; decode_iq_attr_to(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"to">>, <<"iq">>, __TopXMLNS}}); _res -> _res end. encode_iq_attr_to(undefined, _acc) -> _acc; encode_iq_attr_to(_val, _acc) -> [{<<"to">>, jid:encode(_val)} | _acc]. 'decode_iq_attr_xml:lang'(__TopXMLNS, undefined) -> <<>>; 'decode_iq_attr_xml:lang'(__TopXMLNS, _val) -> case catch xmpp_lang:check(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"xml:lang">>, <<"iq">>, __TopXMLNS}}); _res -> _res end. 'encode_iq_attr_xml:lang'(<<>>, _acc) -> _acc; 'encode_iq_attr_xml:lang'(_val, _acc) -> [{<<"xml:lang">>, _val} | _acc]. xmpp-1.4.4/src/xep0114.erl0000644000232200023220000000357413610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0114). -compile(export_all). do_decode(<<"handshake">>, <<"jabber:component:accept">>, El, Opts) -> decode_handshake(<<"jabber:component:accept">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"handshake">>, <<"jabber:component:accept">>}]. do_encode({handshake, _} = Handshake, TopXMLNS) -> encode_handshake(Handshake, TopXMLNS). do_get_name({handshake, _}) -> <<"handshake">>. do_get_ns({handshake, _}) -> <<"jabber:component:accept">>. pp(handshake, 1) -> [data]; pp(_, _) -> no. records() -> [{handshake, 1}]. decode_handshake(__TopXMLNS, __Opts, {xmlel, <<"handshake">>, _attrs, _els}) -> Data = decode_handshake_els(__TopXMLNS, __Opts, _els, <<>>), {handshake, Data}. decode_handshake_els(__TopXMLNS, __Opts, [], Data) -> decode_handshake_cdata(__TopXMLNS, Data); decode_handshake_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_handshake_els(__TopXMLNS, __Opts, _els, <>); decode_handshake_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_handshake_els(__TopXMLNS, __Opts, _els, Data). encode_handshake({handshake, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:component:accept">>, [], __TopXMLNS), _els = encode_handshake_cdata(Data, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"handshake">>, _attrs, _els}. decode_handshake_cdata(__TopXMLNS, <<>>) -> <<>>; decode_handshake_cdata(__TopXMLNS, _val) -> _val. encode_handshake_cdata(<<>>, _acc) -> _acc; encode_handshake_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xep0047.erl0000644000232200023220000002142513610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0047). -compile(export_all). do_decode(<<"close">>, <<"http://jabber.org/protocol/ibb">>, El, Opts) -> decode_ibb_close(<<"http://jabber.org/protocol/ibb">>, Opts, El); do_decode(<<"data">>, <<"http://jabber.org/protocol/ibb">>, El, Opts) -> decode_ibb_data(<<"http://jabber.org/protocol/ibb">>, Opts, El); do_decode(<<"open">>, <<"http://jabber.org/protocol/ibb">>, El, Opts) -> decode_ibb_open(<<"http://jabber.org/protocol/ibb">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"close">>, <<"http://jabber.org/protocol/ibb">>}, {<<"data">>, <<"http://jabber.org/protocol/ibb">>}, {<<"open">>, <<"http://jabber.org/protocol/ibb">>}]. do_encode({ibb_open, _, _, _} = Open, TopXMLNS) -> encode_ibb_open(Open, TopXMLNS); do_encode({ibb_data, _, _, _} = Data, TopXMLNS) -> encode_ibb_data(Data, TopXMLNS); do_encode({ibb_close, _} = Close, TopXMLNS) -> encode_ibb_close(Close, TopXMLNS). do_get_name({ibb_close, _}) -> <<"close">>; do_get_name({ibb_data, _, _, _}) -> <<"data">>; do_get_name({ibb_open, _, _, _}) -> <<"open">>. do_get_ns({ibb_close, _}) -> <<"http://jabber.org/protocol/ibb">>; do_get_ns({ibb_data, _, _, _}) -> <<"http://jabber.org/protocol/ibb">>; do_get_ns({ibb_open, _, _, _}) -> <<"http://jabber.org/protocol/ibb">>. pp(ibb_open, 3) -> [sid, 'block-size', stanza]; pp(ibb_data, 3) -> [sid, seq, data]; pp(ibb_close, 1) -> [sid]; pp(_, _) -> no. records() -> [{ibb_open, 3}, {ibb_data, 3}, {ibb_close, 1}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_int(Int) -> erlang:integer_to_binary(Int). decode_ibb_close(__TopXMLNS, __Opts, {xmlel, <<"close">>, _attrs, _els}) -> Sid = decode_ibb_close_attrs(__TopXMLNS, _attrs, undefined), {ibb_close, Sid}. decode_ibb_close_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], _Sid) -> decode_ibb_close_attrs(__TopXMLNS, _attrs, _val); decode_ibb_close_attrs(__TopXMLNS, [_ | _attrs], Sid) -> decode_ibb_close_attrs(__TopXMLNS, _attrs, Sid); decode_ibb_close_attrs(__TopXMLNS, [], Sid) -> decode_ibb_close_attr_sid(__TopXMLNS, Sid). encode_ibb_close({ibb_close, Sid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/ibb">>, [], __TopXMLNS), _els = [], _attrs = encode_ibb_close_attr_sid(Sid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"close">>, _attrs, _els}. decode_ibb_close_attr_sid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"sid">>, <<"close">>, __TopXMLNS}}); decode_ibb_close_attr_sid(__TopXMLNS, _val) -> _val. encode_ibb_close_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. decode_ibb_data(__TopXMLNS, __Opts, {xmlel, <<"data">>, _attrs, _els}) -> Data = decode_ibb_data_els(__TopXMLNS, __Opts, _els, <<>>), {Sid, Seq} = decode_ibb_data_attrs(__TopXMLNS, _attrs, undefined, undefined), {ibb_data, Sid, Seq, Data}. decode_ibb_data_els(__TopXMLNS, __Opts, [], Data) -> decode_ibb_data_cdata(__TopXMLNS, Data); decode_ibb_data_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_ibb_data_els(__TopXMLNS, __Opts, _els, <>); decode_ibb_data_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_ibb_data_els(__TopXMLNS, __Opts, _els, Data). decode_ibb_data_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], _Sid, Seq) -> decode_ibb_data_attrs(__TopXMLNS, _attrs, _val, Seq); decode_ibb_data_attrs(__TopXMLNS, [{<<"seq">>, _val} | _attrs], Sid, _Seq) -> decode_ibb_data_attrs(__TopXMLNS, _attrs, Sid, _val); decode_ibb_data_attrs(__TopXMLNS, [_ | _attrs], Sid, Seq) -> decode_ibb_data_attrs(__TopXMLNS, _attrs, Sid, Seq); decode_ibb_data_attrs(__TopXMLNS, [], Sid, Seq) -> {decode_ibb_data_attr_sid(__TopXMLNS, Sid), decode_ibb_data_attr_seq(__TopXMLNS, Seq)}. encode_ibb_data({ibb_data, Sid, Seq, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/ibb">>, [], __TopXMLNS), _els = encode_ibb_data_cdata(Data, []), _attrs = encode_ibb_data_attr_seq(Seq, encode_ibb_data_attr_sid(Sid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"data">>, _attrs, _els}. decode_ibb_data_attr_sid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"sid">>, <<"data">>, __TopXMLNS}}); decode_ibb_data_attr_sid(__TopXMLNS, _val) -> _val. encode_ibb_data_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. decode_ibb_data_attr_seq(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"seq">>, <<"data">>, __TopXMLNS}}); decode_ibb_data_attr_seq(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"seq">>, <<"data">>, __TopXMLNS}}); _res -> _res end. encode_ibb_data_attr_seq(_val, _acc) -> [{<<"seq">>, enc_int(_val)} | _acc]. decode_ibb_data_cdata(__TopXMLNS, <<>>) -> <<>>; decode_ibb_data_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"data">>, __TopXMLNS}}); _res -> _res end. encode_ibb_data_cdata(<<>>, _acc) -> _acc; encode_ibb_data_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. decode_ibb_open(__TopXMLNS, __Opts, {xmlel, <<"open">>, _attrs, _els}) -> {Sid, Block_size, Stanza} = decode_ibb_open_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {ibb_open, Sid, Block_size, Stanza}. decode_ibb_open_attrs(__TopXMLNS, [{<<"sid">>, _val} | _attrs], _Sid, Block_size, Stanza) -> decode_ibb_open_attrs(__TopXMLNS, _attrs, _val, Block_size, Stanza); decode_ibb_open_attrs(__TopXMLNS, [{<<"block-size">>, _val} | _attrs], Sid, _Block_size, Stanza) -> decode_ibb_open_attrs(__TopXMLNS, _attrs, Sid, _val, Stanza); decode_ibb_open_attrs(__TopXMLNS, [{<<"stanza">>, _val} | _attrs], Sid, Block_size, _Stanza) -> decode_ibb_open_attrs(__TopXMLNS, _attrs, Sid, Block_size, _val); decode_ibb_open_attrs(__TopXMLNS, [_ | _attrs], Sid, Block_size, Stanza) -> decode_ibb_open_attrs(__TopXMLNS, _attrs, Sid, Block_size, Stanza); decode_ibb_open_attrs(__TopXMLNS, [], Sid, Block_size, Stanza) -> {decode_ibb_open_attr_sid(__TopXMLNS, Sid), 'decode_ibb_open_attr_block-size'(__TopXMLNS, Block_size), decode_ibb_open_attr_stanza(__TopXMLNS, Stanza)}. encode_ibb_open({ibb_open, Sid, Block_size, Stanza}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/ibb">>, [], __TopXMLNS), _els = [], _attrs = encode_ibb_open_attr_stanza(Stanza, 'encode_ibb_open_attr_block-size'(Block_size, encode_ibb_open_attr_sid(Sid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"open">>, _attrs, _els}. decode_ibb_open_attr_sid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"sid">>, <<"open">>, __TopXMLNS}}); decode_ibb_open_attr_sid(__TopXMLNS, _val) -> _val. encode_ibb_open_attr_sid(_val, _acc) -> [{<<"sid">>, _val} | _acc]. 'decode_ibb_open_attr_block-size'(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"block-size">>, <<"open">>, __TopXMLNS}}); 'decode_ibb_open_attr_block-size'(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"block-size">>, <<"open">>, __TopXMLNS}}); _res -> _res end. 'encode_ibb_open_attr_block-size'(_val, _acc) -> [{<<"block-size">>, enc_int(_val)} | _acc]. decode_ibb_open_attr_stanza(__TopXMLNS, undefined) -> iq; decode_ibb_open_attr_stanza(__TopXMLNS, _val) -> case catch dec_enum(_val, [iq, message]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"stanza">>, <<"open">>, __TopXMLNS}}); _res -> _res end. encode_ibb_open_attr_stanza(iq, _acc) -> _acc; encode_ibb_open_attr_stanza(_val, _acc) -> [{<<"stanza">>, enc_enum(_val)} | _acc]. xmpp-1.4.4/src/xep0231.erl0000644000232200023220000001047613610066730015461 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0231). -compile(export_all). do_decode(<<"data">>, <<"urn:xmpp:bob">>, El, Opts) -> decode_bob_data(<<"urn:xmpp:bob">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"data">>, <<"urn:xmpp:bob">>}]. do_encode({bob_data, _, _, _, _} = Data, TopXMLNS) -> encode_bob_data(Data, TopXMLNS). do_get_name({bob_data, _, _, _, _}) -> <<"data">>. do_get_ns({bob_data, _, _, _, _}) -> <<"urn:xmpp:bob">>. pp(bob_data, 4) -> [cid, 'max-age', type, data]; pp(_, _) -> no. records() -> [{bob_data, 4}]. dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> erlang:integer_to_binary(Int). decode_bob_data(__TopXMLNS, __Opts, {xmlel, <<"data">>, _attrs, _els}) -> Data = decode_bob_data_els(__TopXMLNS, __Opts, _els, <<>>), {Cid, Max_age, Type} = decode_bob_data_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {bob_data, Cid, Max_age, Type, Data}. decode_bob_data_els(__TopXMLNS, __Opts, [], Data) -> decode_bob_data_cdata(__TopXMLNS, Data); decode_bob_data_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_bob_data_els(__TopXMLNS, __Opts, _els, <>); decode_bob_data_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_bob_data_els(__TopXMLNS, __Opts, _els, Data). decode_bob_data_attrs(__TopXMLNS, [{<<"cid">>, _val} | _attrs], _Cid, Max_age, Type) -> decode_bob_data_attrs(__TopXMLNS, _attrs, _val, Max_age, Type); decode_bob_data_attrs(__TopXMLNS, [{<<"max-age">>, _val} | _attrs], Cid, _Max_age, Type) -> decode_bob_data_attrs(__TopXMLNS, _attrs, Cid, _val, Type); decode_bob_data_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Cid, Max_age, _Type) -> decode_bob_data_attrs(__TopXMLNS, _attrs, Cid, Max_age, _val); decode_bob_data_attrs(__TopXMLNS, [_ | _attrs], Cid, Max_age, Type) -> decode_bob_data_attrs(__TopXMLNS, _attrs, Cid, Max_age, Type); decode_bob_data_attrs(__TopXMLNS, [], Cid, Max_age, Type) -> {decode_bob_data_attr_cid(__TopXMLNS, Cid), 'decode_bob_data_attr_max-age'(__TopXMLNS, Max_age), decode_bob_data_attr_type(__TopXMLNS, Type)}. encode_bob_data({bob_data, Cid, Max_age, Type, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:bob">>, [], __TopXMLNS), _els = encode_bob_data_cdata(Data, []), _attrs = encode_bob_data_attr_type(Type, 'encode_bob_data_attr_max-age'(Max_age, encode_bob_data_attr_cid(Cid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"data">>, _attrs, _els}. decode_bob_data_attr_cid(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"cid">>, <<"data">>, __TopXMLNS}}); decode_bob_data_attr_cid(__TopXMLNS, _val) -> _val. encode_bob_data_attr_cid(_val, _acc) -> [{<<"cid">>, _val} | _acc]. 'decode_bob_data_attr_max-age'(__TopXMLNS, undefined) -> undefined; 'decode_bob_data_attr_max-age'(__TopXMLNS, _val) -> case catch dec_int(_val, 0, infinity) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"max-age">>, <<"data">>, __TopXMLNS}}); _res -> _res end. 'encode_bob_data_attr_max-age'(undefined, _acc) -> _acc; 'encode_bob_data_attr_max-age'(_val, _acc) -> [{<<"max-age">>, enc_int(_val)} | _acc]. decode_bob_data_attr_type(__TopXMLNS, undefined) -> <<>>; decode_bob_data_attr_type(__TopXMLNS, _val) -> _val. encode_bob_data_attr_type(<<>>, _acc) -> _acc; encode_bob_data_attr_type(_val, _acc) -> [{<<"type">>, _val} | _acc]. decode_bob_data_cdata(__TopXMLNS, <<>>) -> <<>>; decode_bob_data_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"data">>, __TopXMLNS}}); _res -> _res end. encode_bob_data_cdata(<<>>, _acc) -> _acc; encode_bob_data_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. xmpp-1.4.4/src/xep0328.erl0000644000232200023220000000371113610066730015462 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0328). -compile(export_all). do_decode(<<"jid">>, <<"urn:xmpp:jidprep:0">>, El, Opts) -> decode_jidprep(<<"urn:xmpp:jidprep:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"jid">>, <<"urn:xmpp:jidprep:0">>}]. do_encode({jidprep, _} = Jid, TopXMLNS) -> encode_jidprep(Jid, TopXMLNS). do_get_name({jidprep, _}) -> <<"jid">>. do_get_ns({jidprep, _}) -> <<"urn:xmpp:jidprep:0">>. pp(jidprep, 1) -> [jid]; pp(_, _) -> no. records() -> [{jidprep, 1}]. decode_jidprep(__TopXMLNS, __Opts, {xmlel, <<"jid">>, _attrs, _els}) -> Jid = decode_jidprep_els(__TopXMLNS, __Opts, _els, <<>>), {jidprep, Jid}. decode_jidprep_els(__TopXMLNS, __Opts, [], Jid) -> decode_jidprep_cdata(__TopXMLNS, Jid); decode_jidprep_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Jid) -> decode_jidprep_els(__TopXMLNS, __Opts, _els, <>); decode_jidprep_els(__TopXMLNS, __Opts, [_ | _els], Jid) -> decode_jidprep_els(__TopXMLNS, __Opts, _els, Jid). encode_jidprep({jidprep, Jid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:jidprep:0">>, [], __TopXMLNS), _els = encode_jidprep_cdata(Jid, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"jid">>, _attrs, _els}. decode_jidprep_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"jid">>, __TopXMLNS}}); decode_jidprep_cdata(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"jid">>, __TopXMLNS}}); _res -> _res end. encode_jidprep_cdata(_val, _acc) -> [{xmlcdata, jid:encode(_val)} | _acc]. xmpp-1.4.4/src/xmpp_stream_out.erl0000644000232200023220000013774413610066730017615 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_stream_out). -define(GEN_SERVER, p1_server). -behaviour(?GEN_SERVER). -protocol({rfc, 6120}). -protocol({xep, 114, '1.6'}). -protocol({xep, 368, '1.0.0'}). %% API -export([start/3, start_link/3, call/3, cast/2, reply/2, connect/1, stop/1, send/2, close/1, close/2, bind/2, establish/1, format_error/1, set_timeout/2, get_transport/1, change_shaper/2]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). %%-define(DBGFSM, true). -ifdef(DBGFSM). -define(FSMOPTS, [{debug, [trace]}]). -else. -define(FSMOPTS, []). -endif. -define(TCP_SEND_TIMEOUT, 15000). -define(NEGOTIATION_TIMEOUT, 30000). -define(DNS_TIMEOUT, 10000). -define(CONNECT_TIMEOUT, 10000). -include("xmpp.hrl"). -include_lib("kernel/include/inet.hrl"). -type state() :: #{owner := pid(), mod := module(), server := binary(), user := binary(), resource := binary(), password := binary(), lang := binary(), remote_server := binary(), xmlns := binary(), codec_options := [xmpp:decode_option()], stream_direction := in | out, stream_timeout := integer() | infinity, stream_id := binary(), stream_encrypted := boolean(), stream_verified := boolean(), stream_authenticated := boolean(), stream_restarted := boolean(), stream_state := stream_state(), stream_remote_id => binary(), ip => {inet:ip_address(), inet:port_number()}, socket => xmpp_socket:socket(), socket_monitor => reference(), sasl_mech => binary(), sasl_mechs_available => [binary()], sasl_mechs_provided => [binary()], sasl_failure => sasl_failure() | binary(), bind_id => binary(), session_response_id => binary(), _ => _}. -type stream_state() :: connecting | wait_for_stream | wait_for_features | wait_for_starttls_response | wait_for_sasl_response | wait_for_bind_response | wait_for_session_response | downgraded | established | disconnected. -type noreply() :: {noreply, state(), timeout()}. -type next_state() :: noreply() | {stop, term(), state()}. -type host_port() :: {inet:hostname(), inet:port_number(), boolean()} | ip_port(). -type ip_port() :: {inet:ip_address(), inet:port_number(), boolean()}. -type h_addr_list() :: [{{integer(), integer(), inet:port_number(), string()}, boolean()}]. -type network_error() :: {error, inet:posix() | atom()}. -type tls_error_reason() :: inet:posix() | atom() | binary(). -type socket_error_reason() :: inet:posix() | atom(). -type stop_reason() :: {idna, bad_string} | {dns, inet:posix() | atom()} | {stream, reset | {in | out, stream_error()}} | {tls, tls_error_reason()} | {pkix, binary()} | {auth, atom() | binary() | string()} | {bind, stanza_error() | undefined} | {socket, socket_error_reason()} | internal_failure. -export_type([state/0, stop_reason/0]). -callback init(list()) -> {ok, state()} | {error, term()} | ignore. -callback handle_cast(term(), state()) -> state(). -callback handle_call(term(), term(), state()) -> state(). -callback handle_info(term(), state()) -> state(). -callback terminate(term(), state()) -> any(). -callback code_change(term(), state(), term()) -> {ok, state()} | {error, term()}. -callback handle_connect(state()) -> state(). -callback handle_stream_start(stream_start(), state()) -> state(). -callback handle_stream_established(state()) -> state(). -callback handle_stream_downgraded(stream_start(), state()) -> state(). -callback handle_stream_end(stop_reason(), state()) -> state(). -callback handle_cdata(binary(), state()) -> state(). -callback handle_send(xmpp_element(), ok | {error, inet:posix()}, state()) -> state(). -callback handle_recv(fxml:xmlel(), xmpp_element() | {error, term()}, state()) -> state(). -callback handle_timeout(state()) -> state(). -callback handle_authenticated_features(stream_features(), state()) -> state(). -callback handle_unauthenticated_features(stream_features(), state()) -> state(). -callback handle_auth_success(xmpp_sasl:mechanism(), state()) -> state(). -callback handle_auth_failure(xmpp_sasl:mechanism(), binary(), state()) -> state(). -callback handle_bind_success(state()) -> state(). -callback handle_bind_failure(stanza_error() | undefined, state()) -> state(). -callback handle_packet(xmpp_element(), state()) -> state(). -callback tls_options(state()) -> [proplists:property()]. -callback tls_required(state()) -> boolean(). -callback tls_verify(state()) -> boolean(). -callback tls_enabled(state()) -> boolean(). -callback resolve(string(), state()) -> [host_port()]. -callback sasl_mechanisms(state()) -> [binary()]. -callback dns_timeout(state()) -> timeout(). -callback dns_retries(state()) -> non_neg_integer(). -callback default_port(state()) -> inet:port_number(). -callback connect_options(inet:ip_address(), list(), state()) -> list(). -callback address_families(state()) -> [inet:address_family()]. -callback connect_timeout(state()) -> timeout(). -optional_callbacks([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3, handle_connect/1, handle_stream_start/2, handle_stream_established/1, handle_stream_downgraded/2, handle_stream_end/2, handle_cdata/2, handle_send/3, handle_recv/3, handle_timeout/1, handle_authenticated_features/2, handle_unauthenticated_features/2, handle_auth_success/2, handle_auth_failure/3, handle_bind_success/1, handle_bind_failure/2, handle_packet/2, tls_options/1, tls_required/1, tls_verify/1, tls_enabled/1, resolve/2, sasl_mechanisms/1, dns_timeout/1, dns_retries/1, default_port/1, connect_options/3, address_families/1, connect_timeout/1]). %%%=================================================================== %%% API %%%=================================================================== start({local, Mod}, Args, Opts) -> ?GEN_SERVER:start({local, Mod}, ?MODULE, [Mod|Args], Opts ++ ?FSMOPTS); start(Mod, Args, Opts) -> ?GEN_SERVER:start(?MODULE, [Mod|Args], Opts ++ ?FSMOPTS). start_link({local, Mod}, Args, Opts) -> ?GEN_SERVER:start_link({local, Mod}, ?MODULE, [Mod|Args], Opts ++ ?FSMOPTS); start_link(Mod, Args, Opts) -> ?GEN_SERVER:start_link(?MODULE, [Mod|Args], Opts ++ ?FSMOPTS). call(Ref, Msg, Timeout) -> ?GEN_SERVER:call(Ref, Msg, Timeout). cast(Ref, Msg) -> ?GEN_SERVER:cast(Ref, Msg). reply(Ref, Reply) -> ?GEN_SERVER:reply(Ref, Reply). -spec connect(pid()) -> ok. connect(Ref) -> cast(Ref, connect). -spec stop(pid()) -> ok; (state()) -> no_return(). stop(Pid) when is_pid(Pid) -> cast(Pid, stop); stop(#{owner := Owner} = State) when Owner == self() -> terminate(normal, State), try erlang:nif_error(normal) catch _:_ -> exit(normal) end; stop(_) -> erlang:error(badarg). -spec send(pid(), xmpp_element()) -> ok; (state(), xmpp_element()) -> state(). send(Pid, Pkt) when is_pid(Pid) -> cast(Pid, {send, Pkt}); send(#{owner := Owner} = State, Pkt) when Owner == self() -> send_pkt(State, Pkt); send(_, _) -> erlang:error(badarg). -spec close(pid()) -> ok; (state()) -> state(). close(Pid) when is_pid(Pid) -> close(Pid, closed); close(#{owner := Owner} = State) when Owner == self() -> close_socket(State); close(_) -> erlang:error(badarg). -spec close(pid(), atom()) -> ok. close(Pid, Reason) -> cast(Pid, {close, Reason}). -spec bind(state(), stream_features()) -> state(). bind(#{stream_authenticated := true} = State, StreamFeatures) -> process_bind(StreamFeatures, State). -spec establish(state()) -> state(). establish(State) -> process_stream_established(State). -spec set_timeout(state(), timeout()) -> state(). set_timeout(#{owner := Owner} = State, Timeout) when Owner == self() -> case Timeout of infinity -> State#{stream_timeout => infinity}; _ -> State#{stream_timeout => current_time() + Timeout} end; set_timeout(_, _) -> erlang:error(badarg). get_transport(#{socket := Socket, owner := Owner}) when Owner == self() -> xmpp_socket:get_transport(Socket); get_transport(_) -> erlang:error(badarg). -spec change_shaper(state(), p1_shaper:state()) -> state(). change_shaper(#{socket := Socket, owner := Owner} = State, Shaper) when Owner == self() -> Socket1 = xmpp_socket:change_shaper(Socket, Shaper), State#{socket => Socket1}; change_shaper(_, _) -> erlang:error(badarg). -spec format_error(stop_reason()) -> binary(). format_error({idna, _}) -> <<"Remote domain is not an IDN hostname">>; format_error({dns, Reason}) -> format("DNS lookup failed: ~s", [format_inet_error(Reason)]); format_error({socket, Reason}) -> format("Connection failed: ~s", [format_inet_error(Reason)]); format_error({pkix, Reason}) -> {_, ErrTxt} = xmpp_stream_pkix:format_error(Reason), format("Peer certificate rejected: ~s", [ErrTxt]); format_error({stream, reset}) -> <<"Stream reset by peer">>; format_error({stream, {in, #stream_error{} = Err}}) -> format("Stream closed by peer: ~s", [xmpp:format_stream_error(Err)]); format_error({stream, {out, #stream_error{} = Err}}) -> format("Stream closed by local host: ~s", [xmpp:format_stream_error(Err)]); format_error({bind, undefined}) -> <<"Resource binding failure: peer reported no reason">>; format_error({bind, #stanza_error{} = Err}) -> format("Resource binding failure: ~s", [xmpp:format_stanza_error(Err)]); format_error({tls, Reason}) -> format("TLS failed: ~s", [format_tls_error(Reason)]); format_error({auth, Reason}) -> format("Authentication failed: ~s", [Reason]); format_error(internal_failure) -> <<"Internal server error">>; format_error(Err) -> format("Unrecognized error: ~w", [Err]). %%%=================================================================== %%% gen_server callbacks %%%=================================================================== -spec init(list()) -> {ok, state(), timeout()} | {stop, term()} | ignore. init([Mod, From, To, Opts]) -> State = #{owner => self(), mod => Mod, server => From, user => <<"">>, resource => <<"">>, password => <<"">>, lang => <<"">>, remote_server => To, xmlns => ?NS_SERVER, codec_options => [ignore_els], stream_direction => out, stream_timeout => current_time() + ?NEGOTIATION_TIMEOUT, stream_id => xmpp_stream:new_id(), stream_encrypted => false, stream_verified => false, stream_authenticated => false, stream_restarted => false, stream_state => connecting}, case try Mod:init([State, Opts]) catch _:undef -> {ok, State} end of {ok, State1} -> {_, State2, Timeout} = noreply(State1), {ok, State2, Timeout}; {error, Reason} -> {stop, Reason}; ignore -> ignore end. -spec handle_call(term(), term(), state()) -> next_state(). handle_call(Call, From, State) -> noreply(try callback(handle_call, Call, From, State) catch _:{?MODULE, undef} -> State end). -spec handle_cast(term(), state()) -> next_state(). handle_cast(connect, #{remote_server := RemoteServer, stream_state := connecting} = State) -> noreply( case idna_to_ascii(RemoteServer) of false -> process_stream_end({idna, bad_string}, State); ASCIIName -> case resolve(ASCIIName, State) of {ok, AddrPorts} -> case connect(AddrPorts, State) of {ok, Socket, {Addr, Port, Encrypted}} -> SocketMonitor = xmpp_socket:monitor(Socket), State1 = State#{ip => {Addr, Port}, socket => Socket, stream_encrypted => Encrypted, socket_monitor => SocketMonitor}, State2 = State1#{stream_state => wait_for_stream}, State3 = try callback(handle_connect, State2) catch _:{?MODULE, undef} -> State2 end, case is_disconnected(State3) of true -> State3; false -> send_header(State3) end; {error, {Class, Why}} -> process_stream_end({Class, Why}, State) end; {error, Why} -> process_stream_end({dns, Why}, State) end end); handle_cast(connect, #{stream_state := disconnected} = State) -> State1 = reset_state(State), handle_cast(connect, State1); handle_cast(connect, State) -> %% Ignoring connection attempts in other states noreply(State); handle_cast({send, Pkt}, State) -> noreply(send_pkt(State, Pkt)); handle_cast(stop, State) -> {stop, normal, State}; handle_cast({close, Reason}, State) -> State1 = close_socket(State), noreply( case is_disconnected(State) of true -> State1; false -> process_stream_end({socket, Reason}, State) end); handle_cast(Cast, State) -> noreply(try callback(handle_cast, Cast, State) catch _:{?MODULE, undef} -> State end). -spec handle_info(term(), state()) -> next_state(). handle_info({'$gen_event', {xmlstreamstart, Name, Attrs}}, #{stream_state := wait_for_stream, xmlns := XMLNS, lang := MyLang} = State) -> El = #xmlel{name = Name, attrs = Attrs}, noreply( try xmpp:decode(El, XMLNS, []) of #stream_start{} = Pkt -> process_stream(Pkt, State); _ -> send_pkt(State, xmpp:serr_invalid_xml()) catch _:{xmpp_codec, Why} -> Txt = xmpp:io_format_error(Why), Lang = select_lang(MyLang, xmpp:get_lang(El)), Err = xmpp:serr_invalid_xml(Txt, Lang), send_pkt(State, Err) end); handle_info({'$gen_event', {xmlstreamerror, Reason}}, #{lang := Lang}= State) -> State1 = send_header(State), noreply( case is_disconnected(State1) of true -> State1; false -> Err = case Reason of <<"XML stanza is too big">> -> xmpp:serr_policy_violation(Reason, Lang); {_, Txt} -> xmpp:serr_not_well_formed(Txt, Lang) end, send_pkt(State1, Err) end); handle_info({'$gen_event', {xmlstreamelement, El}}, #{xmlns := NS, codec_options := Opts} = State) -> noreply( try xmpp:decode(El, NS, Opts) of Pkt -> State1 = try callback(handle_recv, El, Pkt, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> process_element(Pkt, State1) end catch _:{xmpp_codec, Why} -> State1 = try callback(handle_recv, El, {error, Why}, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> process_invalid_xml(State1, El, Why) end end); handle_info({'$gen_all_state_event', {xmlstreamcdata, Data}}, State) -> noreply(try callback(handle_cdata, Data, State) catch _:{?MODULE, undef} -> State end); handle_info({'$gen_event', {xmlstreamend, _}}, State) -> noreply(process_stream_end({stream, reset}, State)); handle_info({'$gen_event', closed}, State) -> noreply(process_stream_end({socket, closed}, State)); handle_info(timeout, #{lang := Lang} = State) -> Disconnected = is_disconnected(State), noreply(try callback(handle_timeout, State) catch _:{?MODULE, undef} when not Disconnected -> Txt = <<"Idle connection">>, send_pkt(State, xmpp:serr_connection_timeout(Txt, Lang)); _:{?MODULE, undef} -> stop(State) end); handle_info({'DOWN', MRef, _Type, _Object, _Info}, #{socket_monitor := MRef} = State) -> noreply(process_stream_end({socket, closed}, State)); handle_info({tcp, _, Data}, #{socket := Socket} = State) -> noreply( case xmpp_socket:recv(Socket, Data) of {ok, NewSocket} -> State#{socket => NewSocket}; {error, Reason} when is_atom(Reason) -> process_stream_end({socket, Reason}, State); {error, Reason} -> %% TODO: make fast_tls return atoms process_stream_end({tls, Reason}, State) end); handle_info({tcp_closed, _}, State) -> handle_info({'$gen_event', closed}, State); handle_info({tcp_error, _, Reason}, State) -> noreply(process_stream_end({socket, Reason}, State)); handle_info({'EXIT', _, Reason}, State) -> {stop, Reason, State}; handle_info(Info, State) -> noreply(try callback(handle_info, Info, State) catch _:{?MODULE, undef} -> State end). -spec terminate(term(), state()) -> any(). terminate(Reason, State) -> case get(already_terminated) of true -> State; _ -> put(already_terminated, true), try callback(terminate, Reason, State) catch _:{?MODULE, undef} -> ok end, send_trailer(State) end. -spec code_change(term(), state(), term()) -> {ok, state()} | {error, term()}. code_change(OldVsn, State, Extra) -> callback(code_change, OldVsn, State, Extra). %%%=================================================================== %%% Internal functions %%%=================================================================== -spec noreply(state()) -> noreply(). noreply(State) -> {noreply, State, get_timeout(State)}. -spec is_disconnected(state()) -> boolean(). is_disconnected(#{stream_state := StreamState}) -> StreamState == disconnected. -spec process_invalid_xml(state(), fxml:xmlel(), term()) -> state(). process_invalid_xml(#{lang := MyLang} = State, El, Reason) -> case xmpp:is_stanza(El) of true -> Txt = xmpp:io_format_error(Reason), Lang = select_lang(MyLang, xmpp:get_lang(El)), send_error(State, El, xmpp:err_bad_request(Txt, Lang)); false -> State end. -spec process_stream_end(stop_reason(), state()) -> state(). process_stream_end(_, #{stream_state := disconnected} = State) -> State; process_stream_end(Reason, State) -> State1 = send_trailer(State), try callback(handle_stream_end, Reason, State1) catch _:{?MODULE, undef} -> stop(State1) end. -spec process_stream(stream_start(), state()) -> state(). process_stream(#stream_start{xmlns = XML_NS, stream_xmlns = STREAM_NS}, #{xmlns := NS} = State) when XML_NS /= NS; STREAM_NS /= ?NS_STREAM -> send_pkt(State, xmpp:serr_invalid_namespace()); process_stream(#stream_start{version = {N, _}}, State) when N > 1 -> send_pkt(State, xmpp:serr_unsupported_version()); process_stream(#stream_start{lang = Lang, id = ID, version = Version} = StreamStart, State) -> State1 = State#{stream_remote_id => ID, lang => Lang}, State2 = try callback(handle_stream_start, StreamStart, State1) catch _:{?MODULE, undef} -> State1 end, case is_disconnected(State2) of true -> State2; false -> case Version of {1, _} -> State2#{stream_state => wait_for_features}; _ -> process_stream_downgrade(StreamStart, State2) end end. -spec process_element(xmpp_element(), state()) -> state(). process_element(Pkt, #{stream_state := StateName} = State) -> case Pkt of #stream_features{} when StateName == wait_for_features -> process_features(Pkt, State); #starttls_proceed{} when StateName == wait_for_starttls_response -> process_starttls(State); #sasl_success{} when StateName == wait_for_sasl_response -> process_sasl_success(State); #sasl_failure{} when StateName == wait_for_sasl_response -> process_sasl_failure(Pkt, State); #stream_error{} -> process_stream_end({stream, {in, Pkt}}, State); _ when is_record(Pkt, stream_features); is_record(Pkt, starttls_proceed); is_record(Pkt, starttls); is_record(Pkt, sasl_auth); is_record(Pkt, sasl_success); is_record(Pkt, sasl_failure); is_record(Pkt, sasl_response); is_record(Pkt, sasl_abort); is_record(Pkt, compress); is_record(Pkt, handshake) -> %% Do not pass this crap upstream State; _ when StateName == wait_for_bind_response -> process_bind_response(Pkt, State); _ when StateName == wait_for_session_response -> process_session_response(Pkt, State); _ -> process_packet(Pkt, State) end. -spec process_features(stream_features(), state()) -> state(). process_features(StreamFeatures, #{stream_authenticated := true} = State) -> try callback(handle_authenticated_features, StreamFeatures, State) catch _:{?MODULE, undef} -> process_bind(StreamFeatures, State) end; process_features(StreamFeatures, #{stream_encrypted := Encrypted, lang := Lang} = State) -> State1 = try callback(handle_unauthenticated_features, StreamFeatures, State) catch _:{?MODULE, undef} -> State end, case is_disconnected(State1) of true -> State1; false -> TLSRequired = is_starttls_required(State1), TLSAvailable = is_starttls_available(State1), try xmpp:try_subtag(StreamFeatures, #starttls{}) of false when TLSRequired and not Encrypted -> Txt = <<"Use of STARTTLS required">>, send_pkt(State1, xmpp:serr_policy_violation(Txt, Lang)); #starttls{required = true} when not TLSAvailable and not Encrypted -> Txt = <<"STARTTLS is disabled in local configuration">>, send_pkt(State1, xmpp:serr_unsupported_feature(Txt, Lang)); #starttls{} when TLSAvailable and not Encrypted -> State2 = State1#{stream_state => wait_for_starttls_response}, send_pkt(State2, #starttls{}); _ -> State2 = process_cert_verification(State1), case is_disconnected(State2) of true -> State2; false -> process_sasl_mechanisms(StreamFeatures, State2) end catch _:{xmpp_codec, Why} -> Txt = xmpp:io_format_error(Why), send_pkt(State1, xmpp:serr_invalid_xml(Txt, Lang)) end end. -spec process_stream_established(state()) -> state(). process_stream_established(#{stream_state := StateName} = State) when StateName == disconnected; StateName == established -> State; process_stream_established(State) -> State1 = State#{stream_authenticated => true, stream_state => established, stream_timeout => infinity}, try callback(handle_stream_established, State1) catch _:{?MODULE, undef} -> State1 end. -spec process_sasl_mechanisms(stream_features(), state()) -> state(). process_sasl_mechanisms(StreamFeatures, State) -> AvailMechs = sasl_mechanisms(State), State1 = State#{sasl_mechs_available => AvailMechs}, try xmpp:try_subtag(StreamFeatures, #sasl_mechanisms{}) of #sasl_mechanisms{list = ProvidedMechs} -> process_sasl_auth(State1#{sasl_mechs_provided => ProvidedMechs}); false -> process_sasl_auth(State1#{sasl_mechs_provided => []}) catch _:{xmpp_codec, Why} -> Txt = xmpp:io_format_error(Why), Lang = maps:get(lang, State), send_pkt(State, xmpp:serr_invalid_xml(Txt, Lang)) end. -spec process_sasl_auth(state()) -> state(). process_sasl_auth(#{stream_encrypted := false, xmlns := ?NS_SERVER} = State) -> State1 = State#{sasl_mechs_available => []}, Txt = case is_starttls_available(State) of true -> <<"Peer doesn't support STARTTLS">>; false -> <<"STARTTLS is disabled in local configuration">> end, process_sasl_failure(Txt, State1); process_sasl_auth(#{sasl_mechs_provided := [], stream_encrypted := Encrypted} = State) -> State1 = State#{sasl_mechs_available => []}, Hint = case Encrypted of true -> <<"; most likely it doesn't accept our certificate">>; false -> <<"">> end, Txt = <<"Peer provided no SASL mechanisms", Hint/binary>>, process_sasl_failure(Txt, State1); process_sasl_auth(#{sasl_mechs_available := []} = State) -> Err = maps:get(sasl_failure, State, <<"No mutually supported SASL mechanisms found">>), process_sasl_failure(Err, State); process_sasl_auth(#{sasl_mechs_available := [Mech|AvailMechs], sasl_mechs_provided := ProvidedMechs} = State) -> State1 = State#{sasl_mechs_available => AvailMechs}, if Mech == <<"EXTERNAL">> orelse Mech == <<"PLAIN">> -> case lists:member(Mech, ProvidedMechs) of true -> Text = make_sasl_authzid(Mech, State1), State2 = State1#{sasl_mech => Mech, stream_state => wait_for_sasl_response}, send(State2, #sasl_auth{mechanism = Mech, text = Text}); false -> process_sasl_auth(State1) end; true -> process_sasl_auth(State1) end. -spec process_starttls(state()) -> state(). process_starttls(#{socket := Socket} = State) -> case starttls(Socket, State) of {ok, TLSSocket} -> State1 = State#{socket => TLSSocket, stream_id => xmpp_stream:new_id(), stream_restarted => true, stream_state => wait_for_stream, stream_encrypted => true}, send_header(State1); {error, Why} -> process_stream_end({tls, Why}, State) end. -spec process_stream_downgrade(stream_start(), state()) -> state(). process_stream_downgrade(StreamStart, #{lang := Lang, stream_encrypted := Encrypted} = State) -> TLSRequired = is_starttls_required(State), if not Encrypted and TLSRequired -> Txt = <<"Use of STARTTLS required">>, send_pkt(State, xmpp:serr_policy_violation(Txt, Lang)); true -> State1 = State#{stream_state => downgraded}, try callback(handle_stream_downgraded, StreamStart, State1) catch _:{?MODULE, undef} -> send_pkt(State1, xmpp:serr_unsupported_version()) end end. -spec process_cert_verification(state()) -> state(). process_cert_verification(#{stream_encrypted := true, stream_verified := false} = State) -> case try callback(tls_verify, State) catch _:{?MODULE, undef} -> true end of true -> case xmpp_stream_pkix:authenticate(State) of {ok, _} -> State#{stream_verified => true}; {error, Why, _Peer} -> process_stream_end({pkix, Why}, State) end; false -> State#{stream_verified => true} end; process_cert_verification(State) -> State. -spec process_sasl_success(state()) -> state(). process_sasl_success(#{socket := Socket, sasl_mech := Mech} = State) -> Socket1 = xmpp_socket:reset_stream(Socket), State1 = State#{socket => Socket1}, State2 = State1#{stream_id => xmpp_stream:new_id(), stream_restarted => true, stream_state => wait_for_stream, stream_authenticated => true}, State3 = reset_sasl_state(State2), State4 = send_header(State3), case is_disconnected(State4) of true -> State4; false -> try callback(handle_auth_success, Mech, State4) catch _:{?MODULE, undef} -> State4 end end. -spec process_sasl_failure(sasl_failure() | binary(), state()) -> state(). process_sasl_failure(Failure, #{sasl_mechs_available := [_|_]} = State) -> process_sasl_auth(State#{sasl_failure => Failure}); process_sasl_failure(#sasl_failure{} = Failure, State) -> Reason = format("Peer responded with error: ~s", [xmpp:format_sasl_error(Failure)]), process_sasl_failure(Reason, State); process_sasl_failure(Reason, State) -> Mech = case maps:get(sasl_mech, State, undefined) of undefined -> case sasl_mechanisms(State) of [] -> <<"EXTERNAL">>; [M|_] -> M end; M -> M end, State1 = reset_sasl_state(State), try callback(handle_auth_failure, Mech, {auth, Reason}, State1) catch _:{?MODULE, undef} -> process_stream_end({auth, Reason}, State1) end. -spec process_bind(stream_features(), state()) -> state(). process_bind(StreamFeatures, #{lang := Lang, xmlns := ?NS_CLIENT, resource := R, stream_state := StateName} = State) when StateName /= established, StateName /= disconnected -> case xmpp:has_subtag(StreamFeatures, #bind{}) of true -> ID = xmpp_stream:new_id(), Pkt = #iq{id = ID, type = set, sub_els = [#bind{resource = R}]}, State1 = State#{stream_state => wait_for_bind_response, bind_id => ID}, try xmpp:try_subtag(StreamFeatures, #xmpp_session{}) of #xmpp_session{optional = false} -> SID = xmpp_stream:new_id(), State2 = State1#{session_response_id => SID}, send_pkt(State2, Pkt); _ -> send_pkt(State1, Pkt) catch _:{xmpp_codec, Why} -> Txt = xmpp:io_format_error(Why), send_pkt(State, xmpp:serr_invalid_xml(Txt, Lang)) end; false -> Txt = <<"Missing resource binding feature">>, send_pkt(State, xmpp:serr_invalid_xml(Txt, Lang)) end; process_bind(_, State) -> process_stream_established(State). -spec process_bind_response(xmpp_element(), state()) -> state(). process_bind_response(#iq{type = result, id = ID} = IQ, #{lang := Lang, bind_id := ID} = State) -> State1 = reset_bind_state(State), try xmpp:try_subtag(IQ, #bind{}) of #bind{jid = #jid{user = U, server = S, resource = R}} -> State2 = State1#{user => U, server => S, resource => R}, case maps:get(session_response_id, State2, undefined) of undefined -> State3 = try callback(handle_bind_success, State2) catch _:{?MODULE, undef} -> State2 end, process_stream_established(State3); SID -> Pkt = #iq{id = SID, type = set, to = jid:make(S), sub_els = [#xmpp_session{}]}, State3 = State2#{stream_state => wait_for_session_response}, send_pkt(State3, Pkt) end; #bind{} -> Txt = <<"Missing element in resource binding response">>, send_pkt(State1, xmpp:serr_invalid_xml(Txt, Lang)); false -> Txt = <<"Missing element in resource binding response">>, send_pkt(State1, xmpp:serr_invalid_xml(Txt, Lang)) catch _:{xmpp_codec, Why} -> Txt = xmpp:io_format_error(Why), send_pkt(State1, xmpp:serr_invalid_xml(Txt, Lang)) end; process_bind_response(#iq{type = error, id = ID} = IQ, #{bind_id := ID} = State) -> Err = xmpp:get_error(IQ), State1 = reset_bind_state(State), State2 = reset_session_state(State1), try callback(handle_bind_failure, Err, State2) catch _:{?MODULE, undef} -> process_stream_end({bind, Err}, State2) end; process_bind_response(Pkt, State) -> process_packet(Pkt, State). -spec process_session_response(xmpp_element(), state()) -> state(). process_session_response(#iq{type = result, id = ID}, #{session_response_id := ID} = State) -> State1 = reset_session_state(State), State2 = try callback(handle_bind_success, State1) catch _:{?MODULE, undef} -> State1 end, process_stream_established(State2); process_session_response(#iq{type = error, id = ID} = IQ, #{session_response_id := ID} = State) -> State1 = reset_session_state(State), Err = xmpp:get_error(IQ), try callback(handle_bind_failure, Err, State1) catch _:{?MODULE, undef} -> process_stream_end({bind, Err}, State1) end; process_session_response(Pkt, State) -> process_packet(Pkt, State). -spec process_packet(xmpp_element(), state()) -> state(). process_packet(Pkt, State) -> Pkt1 = fix_from(Pkt, State), try callback(handle_packet, Pkt1, State) catch _:{?MODULE, undef} -> State end. -spec is_starttls_required(state()) -> boolean(). is_starttls_required(State) -> try callback(tls_required, State) catch _:{?MODULE, undef} -> false end. -spec is_starttls_available(state()) -> boolean(). is_starttls_available(State) -> try callback(tls_enabled, State) catch _:{?MODULE, undef} -> true end. -spec sasl_mechanisms(state()) -> [binary()]. sasl_mechanisms(#{stream_encrypted := Encrypted} = State) -> try callback(sasl_mechanisms, State) of Ms when Encrypted -> Ms; Ms -> lists:delete(<<"EXTERNAL">>, Ms) catch _:{?MODULE, undef} -> if Encrypted -> [<<"EXTERNAL">>]; true -> [] end end. -spec send_header(state()) -> state(). send_header(#{remote_server := RemoteServer, stream_encrypted := Encrypted, lang := Lang, xmlns := NS, user := User, resource := Resource, server := Server} = State) -> NS_DB = if NS == ?NS_SERVER -> ?NS_SERVER_DIALBACK; true -> <<"">> end, From = if Encrypted -> jid:make(User, Server, Resource); NS == ?NS_SERVER -> jid:make(Server); true -> undefined end, StreamStart = #stream_start{xmlns = NS, lang = Lang, stream_xmlns = ?NS_STREAM, db_xmlns = NS_DB, from = From, to = jid:make(RemoteServer), version = {1,0}}, case socket_send(State, StreamStart) of ok -> State; {error, Why} -> process_stream_end({socket, Why}, State) end. -spec send_pkt(state(), xmpp_element() | xmlel()) -> state(). send_pkt(State, Pkt) -> Result = socket_send(State, Pkt), State1 = try callback(handle_send, Pkt, Result, State) catch _:{?MODULE, undef} -> State end, case Result of _ when is_record(Pkt, stream_error) -> process_stream_end({stream, {out, Pkt}}, State1); ok -> State1; {error, _Why} -> % Queue process_stream_end instead of calling it directly, % so we have opurtunity to process incoming queued messages before % terminating session. self() ! {'$gen_event', closed}, State1 end. -spec send_error(state(), xmpp_element() | xmlel(), stanza_error()) -> state(). send_error(State, Pkt, Err) -> case xmpp:is_stanza(Pkt) of true -> case xmpp:get_type(Pkt) of result -> State; error -> State; <<"result">> -> State; <<"error">> -> State; _ -> ErrPkt = xmpp:make_error(Pkt, Err), send_pkt(State, ErrPkt) end; false -> State end. -spec socket_send(state(), xmpp_element() | xmlel() | trailer) -> ok | {error, inet:posix()}. socket_send(#{socket := Socket, xmlns := NS, stream_state := StateName}, Pkt) -> case Pkt of trailer -> xmpp_socket:send_trailer(Socket); #stream_start{} when StateName /= disconnected -> xmpp_socket:send_header(Socket, xmpp:encode(Pkt)); _ when StateName /= disconnected -> xmpp_socket:send_element(Socket, xmpp:encode(Pkt, NS)); _ -> {error, closed} end; socket_send(_, _) -> {error, closed}. -spec send_trailer(state()) -> state(). send_trailer(State) -> socket_send(State, trailer), close_socket(State). -spec close_socket(state()) -> state(). close_socket(State) -> case State of #{socket := Socket} -> xmpp_socket:close(Socket); _ -> ok end, State#{stream_timeout => infinity, stream_state => disconnected}. -spec starttls(term(), state()) -> {ok, term()} | {error, tls_error_reason()}. starttls(Socket, #{xmlns := NS, remote_server := RemoteServer} = State) -> TLSOpts = try callback(tls_options, State) catch _:{?MODULE, undef} -> [] end, SNI = idna_to_ascii(RemoteServer), ALPN = case NS of ?NS_SERVER -> <<"xmpp-server">>; ?NS_CLIENT -> <<"xmpp-client">> end, xmpp_socket:starttls(Socket, [connect, {sni, SNI}, {alpn, [ALPN]}|TLSOpts]). -spec select_lang(binary(), binary()) -> binary(). select_lang(Lang, <<"">>) -> Lang; select_lang(_, Lang) -> Lang. -spec format_inet_error(atom()) -> string(). format_inet_error(closed) -> "connection closed"; format_inet_error(Reason) -> case inet:format_error(Reason) of "unknown POSIX error" -> atom_to_list(Reason); Txt -> Txt end. -spec format_tls_error(atom() | binary()) -> list(). format_tls_error(Reason) when is_atom(Reason) -> format_inet_error(Reason); format_tls_error(Reason) -> binary_to_list(Reason). -spec format(io:format(), list()) -> binary(). format(Fmt, Args) -> iolist_to_binary(io_lib:format(Fmt, Args)). -spec make_sasl_authzid(binary(), state()) -> binary(). make_sasl_authzid(Mech, #{user := User, server := Server, password := Password}) -> case Mech of <<"EXTERNAL">> -> jid:encode(jid:make(User, Server)); <<"PLAIN">> -> JID = jid:encode(jid:make(User, Server)), <> end. -spec fix_from(xmpp_element(), state()) -> xmpp_element(). fix_from(Pkt, #{xmlns := ?NS_CLIENT} = State) -> case xmpp:is_stanza(Pkt) of true -> case xmpp:get_from(Pkt) of undefined -> #{user := U, server := S, resource := R} = State, From = jid:make(U, S, R), xmpp:set_from(Pkt, From); _ -> Pkt end; false -> Pkt end; fix_from(Pkt, _State) -> Pkt. -spec current_time() -> integer(). current_time() -> p1_time_compat:monotonic_time(milli_seconds). -spec get_timeout(state()) -> timeout(). get_timeout(#{stream_timeout := ExpireTime}) -> case ExpireTime of infinity -> infinity; _ -> max(0, ExpireTime - current_time()) end. %%%=================================================================== %%% State resets %%%=================================================================== -spec reset_sasl_state(state()) -> state(). reset_sasl_state(State) -> State1 = maps:remove(sasl_mech, State), State2 = maps:remove(sasl_failure, State1), State3 = maps:remove(sasl_mechs_provided, State2), maps:remove(sasl_mechs_available, State3). -spec reset_connection_state(state()) -> state(). reset_connection_state(State) -> State1 = maps:remove(ip, State), State2 = maps:remove(socket, State1), maps:remove(socket_monitor, State2). -spec reset_stream_state(state()) -> state(). reset_stream_state(State) -> State1 = State#{stream_id => xmpp_stream:new_id(), stream_encrypted => false, stream_verified => false, stream_authenticated => false, stream_restarted => false, stream_state => connecting}, maps:remove(stream_remote_id, State1). -spec reset_bind_state(state()) -> state(). reset_bind_state(State) -> maps:remove(bind_id, State). -spec reset_session_state(state()) -> state(). reset_session_state(State) -> maps:remove(session_response_id, State). -spec reset_state(state()) -> state(). reset_state(State) -> State1 = reset_bind_state(State), State2 = reset_sasl_state(State1), State3 = reset_connection_state(State2), State4 = reset_session_state(State3), reset_stream_state(State4). %%%=================================================================== %%% Connection stuff %%%=================================================================== -spec idna_to_ascii(binary()) -> string() | false. idna_to_ascii(<<$[, _/binary>> = Host) -> %% This is an IPv6 address in 'IP-literal' format (as per RFC7622) %% We remove brackets here case binary:last(Host) of $] -> IPv6 = binary_to_list(binary:part(Host, {1, size(Host)-2})), case inet:parse_ipv6strict_address(IPv6) of {ok, _} -> IPv6; {error, _} -> false end; _ -> false end; idna_to_ascii(Host) -> SHost = binary_to_list(Host), case inet:parse_address(SHost) of {ok, _} -> SHost; {error, _} -> try idna:utf8_to_ascii(Host) catch _:_ -> false end end. -spec resolve(string(), state()) -> {ok, [ip_port()]} | network_error(). resolve(Host, State) -> try callback(resolve, Host, State) of [] -> do_resolve(Host, State); HostPorts -> a_lookup(HostPorts, State) catch _:{?MODULE, undef} -> do_resolve(Host, State) end. -spec do_resolve(string(), state()) -> {ok, [ip_port()]} | network_error(). do_resolve(Host, State) -> case srv_lookup(Host, State) of {error, _Reason} -> DefaultPort = get_default_port(State), a_lookup([{Host, DefaultPort, false}], State); {ok, HostPorts} -> a_lookup(HostPorts, State) end. -spec srv_lookup(string(), state()) -> {ok, [host_port()]} | network_error(). srv_lookup(_Host, #{xmlns := ?NS_COMPONENT}) -> %% Do not attempt to lookup SRV for component connections {error, nxdomain}; srv_lookup(Host, State) -> %% Only perform SRV lookups for FQDN names case string:chr(Host, $.) of 0 -> {error, nxdomain}; _ -> case inet:parse_address(Host) of {ok, _} -> {error, nxdomain}; {error, _} -> case do_srv_lookup(Host, State) of {ok, AddrList} -> h_addr_list_to_host_ports(AddrList); {error, _} = Err -> Err end end end. -spec do_srv_lookup(string(), state()) -> {ok, h_addr_list()} | network_error(). do_srv_lookup(Host, #{xmlns := NS} = State) -> Retries = get_dns_retries(State), SRVType = case NS of ?NS_SERVER -> "-server._tcp."; ?NS_CLIENT -> "-client._tcp." end, TLSAddrs = case is_starttls_available(State) of true -> case do_srv_lookup("_xmpps" ++ SRVType ++ Host, State, Retries) of {ok, HostEnt} -> [{A, true} || A <- HostEnt#hostent.h_addr_list]; {error, _} -> [] end; false -> [] end, case do_srv_lookup("_xmpp" ++ SRVType ++ Host, State, Retries) of {ok, HostEntry} -> Addrs = [{A, false} || A <- HostEntry#hostent.h_addr_list], {ok, TLSAddrs ++ Addrs}; {error, _} when TLSAddrs /= [] -> {ok, TLSAddrs}; {error, _} = Err -> Err end. -spec do_srv_lookup(string(), state(), integer()) -> {ok, inet:hostent()} | network_error(). do_srv_lookup(_SRVName, _State, Retries) when Retries < 1 -> {error, timeout}; do_srv_lookup(SRVName, State, Retries) -> Timeout = get_dns_timeout(State), case inet_res:getbyname(SRVName, srv, Timeout) of {ok, HostEntry} -> {ok, HostEntry}; {error, timeout} -> do_srv_lookup(SRVName, State, Retries - 1); {error, _} = Err -> Err end. -spec a_lookup([host_port()], state()) -> {ok, [ip_port()]} | network_error(). a_lookup(HostPorts, State) -> HostPortFamilies = [{Host, Port, TLS, Family} || {Host, Port, TLS} <- HostPorts, Family <- get_address_families(State)], a_lookup(HostPortFamilies, State, [], {error, nxdomain}). -spec a_lookup([{inet:hostname() | inet:ip_address(), inet:port_number(), boolean(), inet:address_family()}], state(), [ip_port()], network_error()) -> {ok, [ip_port()]} | network_error(). a_lookup([{Addr, Port, TLS, Family}|HostPortFamilies], State, Acc, Err) when is_tuple(Addr) -> Acc1 = if tuple_size(Addr) == 4 andalso Family == inet -> [{Addr, Port, TLS}|Acc]; tuple_size(Addr) == 8 andalso Family == inet6 -> [{Addr, Port, TLS}|Acc]; true -> Acc end, a_lookup(HostPortFamilies, State, Acc1, Err); a_lookup([{Host, Port, TLS, Family}|HostPortFamilies], State, Acc, Err) -> Retries = get_dns_retries(State), case a_lookup(Host, Port, TLS, Family, State, Retries) of {error, Reason} -> a_lookup(HostPortFamilies, State, Acc, {error, Reason}); {ok, AddrPorts} -> a_lookup(HostPortFamilies, State, Acc ++ AddrPorts, Err) end; a_lookup([], _State, [], Err) -> Err; a_lookup([], _State, Acc, _) -> {ok, Acc}. -spec a_lookup(inet:hostname(), inet:port_number(), boolean(), inet:address_family(), state(), integer()) -> {ok, [ip_port()]} | network_error(). a_lookup(_Host, _Port, _TLS, _Family, _State, Retries) when Retries < 1 -> {error, timeout}; a_lookup(Host, Port, TLS, Family, State, Retries) -> Timeout = get_dns_timeout(State), Start = current_time(), case inet:gethostbyname(Host, Family, Timeout) of {error, nxdomain} = Err -> %% inet:gethostbyname/3 doesn't return {error, timeout}, %% so we should check if 'nxdomain' is in fact a result %% of a timeout. %% We also cannot use inet_res:gethostbyname/3 because %% it ignores DNS configuration settings (e.g. /etc/hosts) End = current_time(), if (End - Start) >= Timeout -> a_lookup(Host, Port, TLS, Family, State, Retries - 1); true -> Err end; {error, _} = Err -> Err; {ok, HostEntry} -> host_entry_to_addr_ports(HostEntry, Port, TLS) end. -spec h_addr_list_to_host_ports(h_addr_list()) -> {ok, [host_port(),...]} | {error, nxdomain}. h_addr_list_to_host_ports(AddrList) -> PrioHostPorts = lists:flatmap( fun({{Priority, Weight, Port, Host}, TLS}) -> N = case Weight of 0 -> 0; _ -> (Weight + 1) * p1_rand:uniform() end, [{Priority * 65536 - N, Host, Port, TLS}]; (_) -> [] end, AddrList), HostPorts = [{Host, Port, TLS} || {_Priority, Host, Port, TLS} <- lists:usort(PrioHostPorts)], case HostPorts of [] -> {error, nxdomain}; _ -> {ok, HostPorts} end. -spec host_entry_to_addr_ports(inet:hostent(), inet:port_number(), boolean()) -> {ok, [ip_port()]} | {error, nxdomain}. host_entry_to_addr_ports(#hostent{h_addr_list = AddrList}, Port, TLS) -> AddrPorts = lists:flatmap( fun(Addr) -> try get_addr_type(Addr) of _ -> [{Addr, Port, TLS}] catch _:_ -> [] end end, AddrList), case AddrPorts of [] -> {error, nxdomain}; _ -> {ok, AddrPorts} end. -spec connect([ip_port()], state()) -> {ok, term(), ip_port()} | {error, {socket, socket_error_reason()}} | {error, {tls, tls_error_reason()}}. connect(AddrPorts, State) -> case connect(AddrPorts, State, {error, nxdomain}) of {ok, Socket, {Addr, Port, TLS = true}} -> case starttls(Socket, State) of {ok, TLSSocket} -> {ok, TLSSocket, {Addr, Port, TLS}}; {error, Why} -> {error, {tls, Why}} end; {ok, Socket, {Addr, Port, TLS = false}} -> {ok, Socket, {Addr, Port, TLS}}; {error, Why} -> {error, {socket, Why}} end. -spec connect([ip_port()], state(), network_error()) -> {ok, term(), ip_port()} | network_error(). connect([{Addr, Port, TLS}|AddrPorts], State, _) -> Type = get_addr_type(Addr), Opts = [binary, {packet, 0}, {send_timeout, ?TCP_SEND_TIMEOUT}, {send_timeout_close, true}, {active, false}, Type], Opts1 = try callback(connect_options, Addr, Opts, State) catch _:{?MODULE, undef} -> Opts end, Timeout = get_connect_timeout(State), try xmpp_socket:connect(Addr, Port, Opts1, Timeout) of {ok, Socket} -> {ok, Socket, {Addr, Port, TLS}}; Err -> connect(AddrPorts, State, Err) catch _:badarg -> connect(AddrPorts, State, {error, einval}) end; connect([], _State, Err) -> Err. -spec get_addr_type(inet:ip_address()) -> inet:address_family(). get_addr_type({_, _, _, _}) -> inet; get_addr_type({_, _, _, _, _, _, _, _}) -> inet6. -spec get_dns_timeout(state()) -> timeout(). get_dns_timeout(State) -> Timeout = try callback(dns_timeout, State) catch _:{?MODULE, undef} -> ?DNS_TIMEOUT end, min(Timeout, get_timeout(State)). -spec get_dns_retries(state()) -> non_neg_integer(). get_dns_retries(State) -> try callback(dns_retries, State) catch _:{?MODULE, undef} -> 2 end. -spec get_default_port(state()) -> inet:port_number(). get_default_port(#{xmlns := NS} = State) -> try callback(default_port, State) catch _:{?MODULE, undef} when NS == ?NS_SERVER -> 5269; _:{?MODULE, undef} when NS == ?NS_CLIENT -> 5222 end. -spec get_address_families(state()) -> [inet:address_family()]. get_address_families(State) -> try callback(address_families, State) catch _:{?MODULE, undef} -> [inet, inet6] end. -spec get_connect_timeout(state()) -> timeout(). get_connect_timeout(State) -> Timeout = try callback(connect_timeout, State) catch _:{?MODULE, undef} -> ?CONNECT_TIMEOUT end, min(Timeout, get_timeout(State)). %%%=================================================================== %%% Callbacks %%%=================================================================== callback(F, #{mod := Mod} = State) -> case erlang:function_exported(Mod, F, 1) of true -> Mod:F(State); false -> erlang:error({?MODULE, undef}) end. callback(F, Arg1, #{mod := Mod} = State) -> case erlang:function_exported(Mod, F, 2) of true -> Mod:F(Arg1, State); false -> erlang:error({?MODULE, undef}) end. callback(code_change, OldVsn, #{mod := Mod} = State, Extra) -> %% code_change/3 callback is a special snowflake case erlang:function_exported(Mod, code_change, 3) of true -> Mod:code_change(OldVsn, State, Extra); false -> {ok, State} end; callback(F, Arg1, Arg2, #{mod := Mod} = State) -> case erlang:function_exported(Mod, F, 3) of true -> Mod:F(Arg1, Arg2, State); false -> erlang:error({?MODULE, undef}) end. xmpp-1.4.4/src/xep0092.erl0000644000232200023220000001653113610066730015464 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0092). -compile(export_all). do_decode(<<"query">>, <<"jabber:iq:version">>, El, Opts) -> decode_version(<<"jabber:iq:version">>, Opts, El); do_decode(<<"os">>, <<"jabber:iq:version">>, El, Opts) -> decode_version_os(<<"jabber:iq:version">>, Opts, El); do_decode(<<"version">>, <<"jabber:iq:version">>, El, Opts) -> decode_version_ver(<<"jabber:iq:version">>, Opts, El); do_decode(<<"name">>, <<"jabber:iq:version">>, El, Opts) -> decode_version_name(<<"jabber:iq:version">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"query">>, <<"jabber:iq:version">>}, {<<"os">>, <<"jabber:iq:version">>}, {<<"version">>, <<"jabber:iq:version">>}, {<<"name">>, <<"jabber:iq:version">>}]. do_encode({version, _, _, _} = Query, TopXMLNS) -> encode_version(Query, TopXMLNS). do_get_name({version, _, _, _}) -> <<"query">>. do_get_ns({version, _, _, _}) -> <<"jabber:iq:version">>. pp(version, 3) -> [name, ver, os]; pp(_, _) -> no. records() -> [{version, 3}]. decode_version(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Ver, Os, Name} = decode_version_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined), {version, Name, Ver, Os}. decode_version_els(__TopXMLNS, __Opts, [], Ver, Os, Name) -> {Ver, Os, Name}; decode_version_els(__TopXMLNS, __Opts, [{xmlel, <<"name">>, _attrs, _} = _el | _els], Ver, Os, Name) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:version">> -> decode_version_els(__TopXMLNS, __Opts, _els, Ver, Os, decode_version_name(<<"jabber:iq:version">>, __Opts, _el)); _ -> decode_version_els(__TopXMLNS, __Opts, _els, Ver, Os, Name) end; decode_version_els(__TopXMLNS, __Opts, [{xmlel, <<"version">>, _attrs, _} = _el | _els], Ver, Os, Name) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:version">> -> decode_version_els(__TopXMLNS, __Opts, _els, decode_version_ver(<<"jabber:iq:version">>, __Opts, _el), Os, Name); _ -> decode_version_els(__TopXMLNS, __Opts, _els, Ver, Os, Name) end; decode_version_els(__TopXMLNS, __Opts, [{xmlel, <<"os">>, _attrs, _} = _el | _els], Ver, Os, Name) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:iq:version">> -> decode_version_els(__TopXMLNS, __Opts, _els, Ver, decode_version_os(<<"jabber:iq:version">>, __Opts, _el), Name); _ -> decode_version_els(__TopXMLNS, __Opts, _els, Ver, Os, Name) end; decode_version_els(__TopXMLNS, __Opts, [_ | _els], Ver, Os, Name) -> decode_version_els(__TopXMLNS, __Opts, _els, Ver, Os, Name). encode_version({version, Name, Ver, Os}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:version">>, [], __TopXMLNS), _els = lists:reverse('encode_version_$ver'(Ver, __NewTopXMLNS, 'encode_version_$os'(Os, __NewTopXMLNS, 'encode_version_$name'(Name, __NewTopXMLNS, [])))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"query">>, _attrs, _els}. 'encode_version_$ver'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_version_$ver'(Ver, __TopXMLNS, _acc) -> [encode_version_ver(Ver, __TopXMLNS) | _acc]. 'encode_version_$os'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_version_$os'(Os, __TopXMLNS, _acc) -> [encode_version_os(Os, __TopXMLNS) | _acc]. 'encode_version_$name'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_version_$name'(Name, __TopXMLNS, _acc) -> [encode_version_name(Name, __TopXMLNS) | _acc]. decode_version_os(__TopXMLNS, __Opts, {xmlel, <<"os">>, _attrs, _els}) -> Cdata = decode_version_os_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_version_os_els(__TopXMLNS, __Opts, [], Cdata) -> decode_version_os_cdata(__TopXMLNS, Cdata); decode_version_os_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_version_os_els(__TopXMLNS, __Opts, _els, <>); decode_version_os_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_version_os_els(__TopXMLNS, __Opts, _els, Cdata). encode_version_os(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:version">>, [], __TopXMLNS), _els = encode_version_os_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"os">>, _attrs, _els}. decode_version_os_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"os">>, __TopXMLNS}}); decode_version_os_cdata(__TopXMLNS, _val) -> _val. encode_version_os_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_version_ver(__TopXMLNS, __Opts, {xmlel, <<"version">>, _attrs, _els}) -> Cdata = decode_version_ver_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_version_ver_els(__TopXMLNS, __Opts, [], Cdata) -> decode_version_ver_cdata(__TopXMLNS, Cdata); decode_version_ver_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_version_ver_els(__TopXMLNS, __Opts, _els, <>); decode_version_ver_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_version_ver_els(__TopXMLNS, __Opts, _els, Cdata). encode_version_ver(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:version">>, [], __TopXMLNS), _els = encode_version_ver_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"version">>, _attrs, _els}. decode_version_ver_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"version">>, __TopXMLNS}}); decode_version_ver_cdata(__TopXMLNS, _val) -> _val. encode_version_ver_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_version_name(__TopXMLNS, __Opts, {xmlel, <<"name">>, _attrs, _els}) -> Cdata = decode_version_name_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_version_name_els(__TopXMLNS, __Opts, [], Cdata) -> decode_version_name_cdata(__TopXMLNS, Cdata); decode_version_name_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_version_name_els(__TopXMLNS, __Opts, _els, <>); decode_version_name_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_version_name_els(__TopXMLNS, __Opts, _els, Cdata). encode_version_name(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:iq:version">>, [], __TopXMLNS), _els = encode_version_name_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"name">>, _attrs, _els}. decode_version_name_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"name">>, __TopXMLNS}}); decode_version_name_cdata(__TopXMLNS, _val) -> _val. encode_version_name_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/pubsub_node_config.erl0000644000232200023220000016413013610066730020206 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_node_config.xdata %% Form type: http://jabber.org/protocol/pubsub#node_config %% Document: XEP-0060 -module(pubsub_node_config). -compile({nowarn_unused_function, [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]}). -compile(nowarn_unused_vars). -dialyzer({nowarn_function, {dec_int, 3}}). -export([encode/1, encode/2, encode/3]). -export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]). -include("xmpp_codec.hrl"). -include("pubsub_node_config.hrl"). -export_type([property/0, result/0, form/0, error_reason/0]). -define(T(S), <>). -spec format_error(error_reason()) -> binary(). -spec io_format_error(error_reason()) -> {binary(), [binary()]}. -spec decode([xdata_field()]) -> result(). -spec decode([xdata_field()], [binary(), ...]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()]) -> result(). -spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result(). -spec do_decode([xdata_field()], binary(), [binary()], result()) -> result(). -spec encode(form()) -> [xdata_field()]. -spec encode(form(), binary()) -> [xdata_field()]. -spec encode(form(), binary(), [access_model | body_xslt | children_association_policy | children_association_whitelist | children | children_max | collection | contact | dataform_xslt | deliver_notifications | deliver_payloads | description | item_expire | itemreply | language | max_items | max_payload_size | node_type | notification_type | notify_config | notify_delete | notify_retract | notify_sub | persist_items | presence_based_delivery | publish_model | purge_offline | roster_groups_allowed | send_last_published_item | tempsub | subscribe | title | type]) -> [xdata_field()]. dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0, 0, 0, 0, 0, 65535, A, B}) -> enc_ip({(A bsr 8) band 255, A band 255, (B bsr 8) band 255, B band 255}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type " "'~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type " "'~s'">>, [Var, Type]}. decode(Fs) -> decode(Fs, [<<"http://jabber.org/protocol/pubsub#node_config">>], [], []). decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, [], []). decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []). decode(Fs, [_ | _] = XMLNSList, Required, Acc) -> case lists:keyfind(<<"FORM_TYPE">>, #xdata_field.var, Fs) of false -> do_decode(Fs, hd(XMLNSList), Required, Acc); #xdata_field{values = [XMLNS]} -> case lists:member(XMLNS, XMLNSList) of true -> do_decode(Fs, XMLNS, Required, Acc); false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}}) end end. encode(Cfg) -> encode(Cfg, <<"en">>, []). encode(Cfg, Lang) -> encode(Cfg, Lang, []). encode(List, Lang, Required) -> Fs = [case Opt of {access_model, Val} -> [encode_access_model(Val, default, Lang, lists:member(access_model, Required))]; {access_model, Val, Opts} -> [encode_access_model(Val, Opts, Lang, lists:member(access_model, Required))]; {body_xslt, Val} -> [encode_body_xslt(Val, Lang, lists:member(body_xslt, Required))]; {children_association_policy, Val} -> [encode_children_association_policy(Val, default, Lang, lists:member(children_association_policy, Required))]; {children_association_policy, Val, Opts} -> [encode_children_association_policy(Val, Opts, Lang, lists:member(children_association_policy, Required))]; {children_association_whitelist, Val} -> [encode_children_association_whitelist(Val, Lang, lists:member(children_association_whitelist, Required))]; {children, Val} -> [encode_children(Val, Lang, lists:member(children, Required))]; {children_max, Val} -> [encode_children_max(Val, Lang, lists:member(children_max, Required))]; {collection, Val} -> [encode_collection(Val, Lang, lists:member(collection, Required))]; {contact, Val} -> [encode_contact(Val, Lang, lists:member(contact, Required))]; {dataform_xslt, Val} -> [encode_dataform_xslt(Val, Lang, lists:member(dataform_xslt, Required))]; {deliver_notifications, Val} -> [encode_deliver_notifications(Val, Lang, lists:member(deliver_notifications, Required))]; {deliver_payloads, Val} -> [encode_deliver_payloads(Val, Lang, lists:member(deliver_payloads, Required))]; {description, Val} -> [encode_description(Val, Lang, lists:member(description, Required))]; {item_expire, Val} -> [encode_item_expire(Val, Lang, lists:member(item_expire, Required))]; {itemreply, Val} -> [encode_itemreply(Val, default, Lang, lists:member(itemreply, Required))]; {itemreply, Val, Opts} -> [encode_itemreply(Val, Opts, Lang, lists:member(itemreply, Required))]; {language, Val} -> [encode_language(Val, default, Lang, lists:member(language, Required))]; {language, Val, Opts} -> [encode_language(Val, Opts, Lang, lists:member(language, Required))]; {max_items, Val} -> [encode_max_items(Val, Lang, lists:member(max_items, Required))]; {max_payload_size, Val} -> [encode_max_payload_size(Val, Lang, lists:member(max_payload_size, Required))]; {node_type, Val} -> [encode_node_type(Val, default, Lang, lists:member(node_type, Required))]; {node_type, Val, Opts} -> [encode_node_type(Val, Opts, Lang, lists:member(node_type, Required))]; {notification_type, Val} -> [encode_notification_type(Val, default, Lang, lists:member(notification_type, Required))]; {notification_type, Val, Opts} -> [encode_notification_type(Val, Opts, Lang, lists:member(notification_type, Required))]; {notify_config, Val} -> [encode_notify_config(Val, Lang, lists:member(notify_config, Required))]; {notify_delete, Val} -> [encode_notify_delete(Val, Lang, lists:member(notify_delete, Required))]; {notify_retract, Val} -> [encode_notify_retract(Val, Lang, lists:member(notify_retract, Required))]; {notify_sub, Val} -> [encode_notify_sub(Val, Lang, lists:member(notify_sub, Required))]; {persist_items, Val} -> [encode_persist_items(Val, Lang, lists:member(persist_items, Required))]; {presence_based_delivery, Val} -> [encode_presence_based_delivery(Val, Lang, lists:member(presence_based_delivery, Required))]; {publish_model, Val} -> [encode_publish_model(Val, default, Lang, lists:member(publish_model, Required))]; {publish_model, Val, Opts} -> [encode_publish_model(Val, Opts, Lang, lists:member(publish_model, Required))]; {purge_offline, Val} -> [encode_purge_offline(Val, Lang, lists:member(purge_offline, Required))]; {roster_groups_allowed, Val} -> [encode_roster_groups_allowed(Val, default, Lang, lists:member(roster_groups_allowed, Required))]; {roster_groups_allowed, Val, Opts} -> [encode_roster_groups_allowed(Val, Opts, Lang, lists:member(roster_groups_allowed, Required))]; {send_last_published_item, Val} -> [encode_send_last_published_item(Val, default, Lang, lists:member(send_last_published_item, Required))]; {send_last_published_item, Val, Opts} -> [encode_send_last_published_item(Val, Opts, Lang, lists:member(send_last_published_item, Required))]; {tempsub, Val} -> [encode_tempsub(Val, Lang, lists:member(tempsub, Required))]; {subscribe, Val} -> [encode_subscribe(Val, Lang, lists:member(subscribe, Required))]; {title, Val} -> [encode_title(Val, Lang, lists:member(title, Required))]; {type, Val} -> [encode_type(Val, Lang, lists:member(type, Required))]; #xdata_field{} -> [Opt] end || Opt <- List], FormType = #xdata_field{var = <<"FORM_TYPE">>, type = hidden, values = [<<"http://jabber.org/protocol/pubsub#node_config">>]}, [FormType | lists:flatten(Fs)]. do_decode([#xdata_field{var = <<"pubsub#access_model">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [authorize, open, presence, roster, whitelist]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#access_model">>, Required), [{access_model, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#access_model">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#access_model">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#access_model">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#access_model">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#access_model">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#body_xslt">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#body_xslt">>, Required), [{body_xslt, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#body_xslt">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#body_xslt">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#body_xslt">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#body_xslt">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#body_xslt">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#children_association_policy">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [all, owners, whitelist]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#children_association_policy">>, Required), [{children_association_policy, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#children_association_policy">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#children_association_policy">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#children_association_policy">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#children_association_policy">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#children_association_policy">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#children_association_whitelist">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"pubsub#children_association_whitelist">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#children_association_whitelist">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#children_association_whitelist">>, Required), [{children_association_whitelist, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#children_association_whitelist">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#children">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [Value || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#children">>, Required), [{children, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#children">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#children_max">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#children_max">>, Required), [{children_max, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#children_max">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#children_max">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#children_max">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#children_max">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#children_max">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#collection">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [Value || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#collection">>, Required), [{collection, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#collection">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#contact">>, values = [<<>>]} = F | Fs], XMLNS, Required, Acc) -> %% Psi work-around do_decode([F#xdata_field{var = <<"pubsub#contact">>, values = []} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#contact">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [jid:decode(Value) || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#contact">>, Required), [{contact, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#contact">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#dataform_xslt">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#dataform_xslt">>, Required), [{dataform_xslt, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#dataform_xslt">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#dataform_xslt">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#dataform_xslt">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#dataform_xslt">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#dataform_xslt">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#deliver_notifications">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#deliver_notifications">>, Required), [{deliver_notifications, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#deliver_notifications">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#deliver_notifications">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#deliver_notifications">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#deliver_notifications">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#deliver_notifications">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#deliver_payloads">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#deliver_payloads">>, Required), [{deliver_payloads, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#deliver_payloads">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#deliver_payloads">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#deliver_payloads">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#deliver_payloads">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#deliver_payloads">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#description">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#description">>, Required), [{description, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#description">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#description">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#description">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#description">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#description">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#item_expire">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#item_expire">>, Required), [{item_expire, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#item_expire">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#item_expire">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#item_expire">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#item_expire">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#item_expire">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#itemreply">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [owner, publisher, none]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#itemreply">>, Required), [{itemreply, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#itemreply">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#itemreply">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#itemreply">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#itemreply">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#itemreply">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#language">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#language">>, Required), [{language, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#language">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#language">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#language">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#language">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#language">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#max_items">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#max_items">>, Required), [{max_items, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#max_items">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#max_items">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#max_items">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#max_items">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#max_items">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#max_payload_size">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_int(Value, 0, infinity) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#max_payload_size">>, Required), [{max_payload_size, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#max_payload_size">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#max_payload_size">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#max_payload_size">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#max_payload_size">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#max_payload_size">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#node_type">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [leaf, collection]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#node_type">>, Required), [{node_type, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#node_type">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#node_type">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#node_type">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#node_type">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#node_type">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#notification_type">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [normal, headline]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#notification_type">>, Required), [{notification_type, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#notification_type">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#notification_type">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#notification_type">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#notification_type">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#notification_type">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#notify_config">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#notify_config">>, Required), [{notify_config, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#notify_config">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#notify_config">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#notify_config">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#notify_config">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#notify_config">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#notify_delete">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#notify_delete">>, Required), [{notify_delete, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#notify_delete">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#notify_delete">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#notify_delete">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#notify_delete">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#notify_delete">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#notify_retract">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#notify_retract">>, Required), [{notify_retract, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#notify_retract">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#notify_retract">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#notify_retract">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#notify_retract">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#notify_retract">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#notify_sub">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#notify_sub">>, Required), [{notify_sub, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#notify_sub">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#notify_sub">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#notify_sub">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#notify_sub">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#notify_sub">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#persist_items">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#persist_items">>, Required), [{persist_items, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#persist_items">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#persist_items">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#persist_items">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#persist_items">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#persist_items">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#presence_based_delivery">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#presence_based_delivery">>, Required), [{presence_based_delivery, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#presence_based_delivery">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#presence_based_delivery">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#presence_based_delivery">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#presence_based_delivery">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#presence_based_delivery">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#publish_model">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [publishers, subscribers, open]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#publish_model">>, Required), [{publish_model, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#publish_model">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#publish_model">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#publish_model">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#publish_model">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#publish_model">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#purge_offline">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#purge_offline">>, Required), [{purge_offline, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#purge_offline">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#purge_offline">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#purge_offline">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#purge_offline">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#purge_offline">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#roster_groups_allowed">>, values = Values} | Fs], XMLNS, Required, Acc) -> try [Value || Value <- Values] of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#roster_groups_allowed">>, Required), [{roster_groups_allowed, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#roster_groups_allowed">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#send_last_published_item">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_enum(Value, [never, on_sub, on_sub_and_presence]) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#send_last_published_item">>, Required), [{send_last_published_item, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#send_last_published_item">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#send_last_published_item">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#send_last_published_item">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#send_last_published_item">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#send_last_published_item">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#tempsub">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#tempsub">>, Required), [{tempsub, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#tempsub">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#tempsub">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#tempsub">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#tempsub">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#tempsub">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#subscribe">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try dec_bool(Value) of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#subscribe">>, Required), [{subscribe, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#subscribe">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#subscribe">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#subscribe">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#subscribe">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#subscribe">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#title">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#title">>, Required), [{title, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#title">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#title">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#title">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#title">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#title">>, XMLNS}}); do_decode([#xdata_field{var = <<"pubsub#type">>, values = [Value]} | Fs], XMLNS, Required, Acc) -> try Value of Result -> do_decode(Fs, XMLNS, lists:delete(<<"pubsub#type">>, Required), [{type, Result} | Acc]) catch _:_ -> erlang:error({?MODULE, {bad_var_value, <<"pubsub#type">>, XMLNS}}) end; do_decode([#xdata_field{var = <<"pubsub#type">>, values = []} = F | Fs], XMLNS, Required, Acc) -> do_decode([F#xdata_field{var = <<"pubsub#type">>, values = [<<>>]} | Fs], XMLNS, Required, Acc); do_decode([#xdata_field{var = <<"pubsub#type">>} | _], XMLNS, _, _) -> erlang:error({?MODULE, {too_many_values, <<"pubsub#type">>, XMLNS}}); do_decode([#xdata_field{var = Var} | Fs], XMLNS, Required, Acc) -> if Var /= <<"FORM_TYPE">> -> erlang:error({?MODULE, {unknown_var, Var, XMLNS}}); true -> do_decode(Fs, XMLNS, Required, Acc) end; do_decode([], XMLNS, [Var | _], _) -> erlang:error({?MODULE, {missing_required_var, Var, XMLNS}}); do_decode([], _, [], Acc) -> Acc. -spec encode_access_model(access_model() | undefined, default | options(access_model()), binary(), boolean()) -> xdata_field(). encode_access_model(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Subscription requests must be approved " "and only subscribers may retrieve items")), value = <<"authorize">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone may subscribe and retrieve items")), value = <<"open">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone with a presence subscription " "of both or from may subscribe and retrieve " "items")), value = <<"presence">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone in the specified roster group(s) " "may subscribe and retrieve items")), value = <<"roster">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Only those on a whitelist may subscribe " "and retrieve items")), value = <<"whitelist">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#access_model">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Specify the access model"))}. -spec encode_body_xslt(binary(), binary(), boolean()) -> xdata_field(). encode_body_xslt(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#body_xslt">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The URL of an XSL transformation which " "can be applied to payloads in order " "to generate an appropriate message body " "element."))}. -spec encode_children_association_policy(children_association_policy() | undefined, default | options(children_association_policy()), binary(), boolean()) -> xdata_field(). encode_children_association_policy(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone may associate leaf nodes with " "the collection")), value = <<"all">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Only collection node owners may associate " "leaf nodes with the collection")), value = <<"owners">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Only those on a whitelist may associate " "leaf nodes with the collection")), value = <<"whitelist">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#children_association_policy">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Who may associate leaf nodes with a " "collection"))}. -spec encode_children_association_whitelist([jid:jid()], binary(), boolean()) -> xdata_field(). encode_children_association_whitelist(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"pubsub#children_association_whitelist">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The list of JIDs that may associate " "leaf nodes with a collection"))}. -spec encode_children([binary()], binary(), boolean()) -> xdata_field(). encode_children(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> Value end, Opts = [], #xdata_field{var = <<"pubsub#children">>, values = Values, required = IsRequired, type = 'text-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The child nodes (leaf or collection) " "associated with a collection"))}. -spec encode_children_max(binary(), binary(), boolean()) -> xdata_field(). encode_children_max(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#children_max">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The maximum number of child nodes that " "can be associated with a collection"))}. -spec encode_collection([binary()], binary(), boolean()) -> xdata_field(). encode_collection(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> Value end, Opts = [], #xdata_field{var = <<"pubsub#collection">>, values = Values, required = IsRequired, type = 'text-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The collections with which a node is " "affiliated"))}. -spec encode_contact([jid:jid()], binary(), boolean()) -> xdata_field(). encode_contact(Value, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> [jid:encode(V) || V <- Value] end, Opts = [], #xdata_field{var = <<"pubsub#contact">>, values = Values, required = IsRequired, type = 'jid-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The JIDs of those to contact with questions"))}. -spec encode_dataform_xslt(binary(), binary(), boolean()) -> xdata_field(). encode_dataform_xslt(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#dataform_xslt">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The URL of an XSL transformation which " "can be applied to the payload format " "in order to generate a valid Data Forms " "result that the client could display " "using a generic Data Forms rendering " "engine"))}. -spec encode_deliver_notifications(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_deliver_notifications(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#deliver_notifications">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Deliver event notifications"))}. -spec encode_deliver_payloads(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_deliver_payloads(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#deliver_payloads">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Deliver payloads with event notifications"))}. -spec encode_description(binary(), binary(), boolean()) -> xdata_field(). encode_description(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#description">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("A description of the node"))}. -spec encode_item_expire(binary(), binary(), boolean()) -> xdata_field(). encode_item_expire(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#item_expire">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Number of seconds after which to automaticall" "y purge items"))}. -spec encode_itemreply(itemreply() | undefined, default | options(itemreply()), binary(), boolean()) -> xdata_field(). encode_itemreply(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Statically specify a replyto of the " "node owner(s)")), value = <<"owner">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Dynamically specify a replyto of the " "item publisher")), value = <<"publisher">>}, #xdata_option{value = <<"none">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#itemreply">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether owners or publisher should receive " "replies to items"))}. -spec encode_language(binary(), default | options(binary()), binary(), boolean()) -> xdata_field(). encode_language(Value, Options, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = if Options == default -> []; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = V} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#language">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The default language of the node"))}. -spec encode_max_items(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_max_items(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#max_items">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Max # of items to persist"))}. -spec encode_max_payload_size(non_neg_integer() | undefined, binary(), boolean()) -> xdata_field(). encode_max_payload_size(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_int(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#max_payload_size">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Max payload size in bytes"))}. -spec encode_node_type(node_type() | undefined, default | options(node_type()), binary(), boolean()) -> xdata_field(). encode_node_type(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("The node is a leaf node (default)")), value = <<"leaf">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("The node is a collection node")), value = <<"collection">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#node_type">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether the node is a leaf (default) " "or a collection"))}. -spec encode_notification_type(notification_type() | undefined, default | options(notification_type()), binary(), boolean()) -> xdata_field(). encode_notification_type(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Messages of type normal")), value = <<"normal">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Messages of type headline")), value = <<"headline">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#notification_type">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Specify the event message type"))}. -spec encode_notify_config(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_notify_config(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#notify_config">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Notify subscribers when the node configuratio" "n changes"))}. -spec encode_notify_delete(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_notify_delete(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#notify_delete">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Notify subscribers when the node is " "deleted"))}. -spec encode_notify_retract(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_notify_retract(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#notify_retract">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Notify subscribers when items are removed " "from the node"))}. -spec encode_notify_sub(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_notify_sub(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#notify_sub">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether to notify owners about new subscriber" "s and unsubscribes"))}. -spec encode_persist_items(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_persist_items(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#persist_items">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Persist items to storage"))}. -spec encode_presence_based_delivery(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_presence_based_delivery(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#presence_based_delivery">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Only deliver notifications to available " "users"))}. -spec encode_publish_model(publish_model() | undefined, default | options(publish_model()), binary(), boolean()) -> xdata_field(). encode_publish_model(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Only publishers may publish")), value = <<"publishers">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Subscribers may publish")), value = <<"subscribers">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("Anyone may publish")), value = <<"open">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#publish_model">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Specify the publisher model"))}. -spec encode_purge_offline(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_purge_offline(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#purge_offline">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Purge all items when the relevant publisher " "goes offline"))}. -spec encode_roster_groups_allowed([binary()], default | options(binary()), binary(), boolean()) -> xdata_field(). encode_roster_groups_allowed(Value, Options, Lang, IsRequired) -> Values = case Value of [] -> []; Value -> Value end, Opts = if Options == default -> []; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = V} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#roster_groups_allowed">>, values = Values, required = IsRequired, type = 'list-multi', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Roster groups allowed to subscribe"))}. -spec encode_send_last_published_item(send_last_published_item() | undefined, default | options(send_last_published_item()), binary(), boolean()) -> xdata_field(). encode_send_last_published_item(Value, Options, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_enum(Value)] end, Opts = if Options == default -> [#xdata_option{label = xmpp_tr:tr(Lang, ?T("Never")), value = <<"never">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("When a new subscription is processed")), value = <<"on_sub">>}, #xdata_option{label = xmpp_tr:tr(Lang, ?T("When a new subscription is processed " "and whenever a subscriber comes online")), value = <<"on_sub_and_presence">>}]; true -> [#xdata_option{label = xmpp_tr:tr(Lang, L), value = enc_enum(V)} || {L, V} <- Options] end, #xdata_field{var = <<"pubsub#send_last_published_item">>, values = Values, required = IsRequired, type = 'list-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("When to send the last published item"))}. -spec encode_tempsub(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_tempsub(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#tempsub">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether to make all subscriptions temporary, " "based on subscriber presence"))}. -spec encode_subscribe(boolean() | undefined, binary(), boolean()) -> xdata_field(). encode_subscribe(Value, Lang, IsRequired) -> Values = case Value of undefined -> []; Value -> [enc_bool(Value)] end, Opts = [], #xdata_field{var = <<"pubsub#subscribe">>, values = Values, required = IsRequired, type = boolean, options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("Whether to allow subscriptions"))}. -spec encode_title(binary(), binary(), boolean()) -> xdata_field(). encode_title(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#title">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("A friendly name for the node"))}. -spec encode_type(binary(), binary(), boolean()) -> xdata_field(). encode_type(Value, Lang, IsRequired) -> Values = case Value of <<>> -> []; Value -> [Value] end, Opts = [], #xdata_field{var = <<"pubsub#type">>, values = Values, required = IsRequired, type = 'text-single', options = Opts, desc = <<>>, label = xmpp_tr:tr(Lang, ?T("The type of node data, usually specified " "by the namespace of the payload (if " "any)"))}. xmpp-1.4.4/src/xep0022.erl0000644000232200023220000002167213610066730015457 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0022). -compile(export_all). do_decode(<<"x">>, <<"jabber:x:event">>, El, Opts) -> decode_xevent(<<"jabber:x:event">>, Opts, El); do_decode(<<"id">>, <<"jabber:x:event">>, El, Opts) -> decode_xevent_id(<<"jabber:x:event">>, Opts, El); do_decode(<<"composing">>, <<"jabber:x:event">>, El, Opts) -> decode_xevent_composing(<<"jabber:x:event">>, Opts, El); do_decode(<<"displayed">>, <<"jabber:x:event">>, El, Opts) -> decode_xevent_displayed(<<"jabber:x:event">>, Opts, El); do_decode(<<"delivered">>, <<"jabber:x:event">>, El, Opts) -> decode_xevent_delivered(<<"jabber:x:event">>, Opts, El); do_decode(<<"offline">>, <<"jabber:x:event">>, El, Opts) -> decode_xevent_offline(<<"jabber:x:event">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"x">>, <<"jabber:x:event">>}, {<<"id">>, <<"jabber:x:event">>}, {<<"composing">>, <<"jabber:x:event">>}, {<<"displayed">>, <<"jabber:x:event">>}, {<<"delivered">>, <<"jabber:x:event">>}, {<<"offline">>, <<"jabber:x:event">>}]. do_encode({xevent, _, _, _, _, _} = X, TopXMLNS) -> encode_xevent(X, TopXMLNS). do_get_name({xevent, _, _, _, _, _}) -> <<"x">>. do_get_ns({xevent, _, _, _, _, _}) -> <<"jabber:x:event">>. pp(xevent, 5) -> [offline, delivered, displayed, composing, id]; pp(_, _) -> no. records() -> [{xevent, 5}]. decode_xevent(__TopXMLNS, __Opts, {xmlel, <<"x">>, _attrs, _els}) -> {Id, Displayed, Delivered, Offline, Composing} = decode_xevent_els(__TopXMLNS, __Opts, _els, undefined, false, false, false, false), {xevent, Offline, Delivered, Displayed, Composing, Id}. decode_xevent_els(__TopXMLNS, __Opts, [], Id, Displayed, Delivered, Offline, Composing) -> {Id, Displayed, Delivered, Offline, Composing}; decode_xevent_els(__TopXMLNS, __Opts, [{xmlel, <<"offline">>, _attrs, _} = _el | _els], Id, Displayed, Delivered, Offline, Composing) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:event">> -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, decode_xevent_offline(<<"jabber:x:event">>, __Opts, _el), Composing); _ -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, Offline, Composing) end; decode_xevent_els(__TopXMLNS, __Opts, [{xmlel, <<"delivered">>, _attrs, _} = _el | _els], Id, Displayed, Delivered, Offline, Composing) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:event">> -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, decode_xevent_delivered(<<"jabber:x:event">>, __Opts, _el), Offline, Composing); _ -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, Offline, Composing) end; decode_xevent_els(__TopXMLNS, __Opts, [{xmlel, <<"displayed">>, _attrs, _} = _el | _els], Id, Displayed, Delivered, Offline, Composing) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:event">> -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, decode_xevent_displayed(<<"jabber:x:event">>, __Opts, _el), Delivered, Offline, Composing); _ -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, Offline, Composing) end; decode_xevent_els(__TopXMLNS, __Opts, [{xmlel, <<"composing">>, _attrs, _} = _el | _els], Id, Displayed, Delivered, Offline, Composing) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:event">> -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, Offline, decode_xevent_composing(<<"jabber:x:event">>, __Opts, _el)); _ -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, Offline, Composing) end; decode_xevent_els(__TopXMLNS, __Opts, [{xmlel, <<"id">>, _attrs, _} = _el | _els], Id, Displayed, Delivered, Offline, Composing) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:event">> -> decode_xevent_els(__TopXMLNS, __Opts, _els, decode_xevent_id(<<"jabber:x:event">>, __Opts, _el), Displayed, Delivered, Offline, Composing); _ -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, Offline, Composing) end; decode_xevent_els(__TopXMLNS, __Opts, [_ | _els], Id, Displayed, Delivered, Offline, Composing) -> decode_xevent_els(__TopXMLNS, __Opts, _els, Id, Displayed, Delivered, Offline, Composing). encode_xevent({xevent, Offline, Delivered, Displayed, Composing, Id}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:event">>, [], __TopXMLNS), _els = lists:reverse('encode_xevent_$id'(Id, __NewTopXMLNS, 'encode_xevent_$displayed'(Displayed, __NewTopXMLNS, 'encode_xevent_$delivered'(Delivered, __NewTopXMLNS, 'encode_xevent_$offline'(Offline, __NewTopXMLNS, 'encode_xevent_$composing'(Composing, __NewTopXMLNS, [])))))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"x">>, _attrs, _els}. 'encode_xevent_$id'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_xevent_$id'(Id, __TopXMLNS, _acc) -> [encode_xevent_id(Id, __TopXMLNS) | _acc]. 'encode_xevent_$displayed'(false, __TopXMLNS, _acc) -> _acc; 'encode_xevent_$displayed'(Displayed, __TopXMLNS, _acc) -> [encode_xevent_displayed(Displayed, __TopXMLNS) | _acc]. 'encode_xevent_$delivered'(false, __TopXMLNS, _acc) -> _acc; 'encode_xevent_$delivered'(Delivered, __TopXMLNS, _acc) -> [encode_xevent_delivered(Delivered, __TopXMLNS) | _acc]. 'encode_xevent_$offline'(false, __TopXMLNS, _acc) -> _acc; 'encode_xevent_$offline'(Offline, __TopXMLNS, _acc) -> [encode_xevent_offline(Offline, __TopXMLNS) | _acc]. 'encode_xevent_$composing'(false, __TopXMLNS, _acc) -> _acc; 'encode_xevent_$composing'(Composing, __TopXMLNS, _acc) -> [encode_xevent_composing(Composing, __TopXMLNS) | _acc]. decode_xevent_id(__TopXMLNS, __Opts, {xmlel, <<"id">>, _attrs, _els}) -> Cdata = decode_xevent_id_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_xevent_id_els(__TopXMLNS, __Opts, [], Cdata) -> decode_xevent_id_cdata(__TopXMLNS, Cdata); decode_xevent_id_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_xevent_id_els(__TopXMLNS, __Opts, _els, <>); decode_xevent_id_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_xevent_id_els(__TopXMLNS, __Opts, _els, Cdata). encode_xevent_id(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:event">>, [], __TopXMLNS), _els = encode_xevent_id_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"id">>, _attrs, _els}. decode_xevent_id_cdata(__TopXMLNS, <<>>) -> <<>>; decode_xevent_id_cdata(__TopXMLNS, _val) -> _val. encode_xevent_id_cdata(<<>>, _acc) -> _acc; encode_xevent_id_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_xevent_composing(__TopXMLNS, __Opts, {xmlel, <<"composing">>, _attrs, _els}) -> true. encode_xevent_composing(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:event">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"composing">>, _attrs, _els}. decode_xevent_displayed(__TopXMLNS, __Opts, {xmlel, <<"displayed">>, _attrs, _els}) -> true. encode_xevent_displayed(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:event">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"displayed">>, _attrs, _els}. decode_xevent_delivered(__TopXMLNS, __Opts, {xmlel, <<"delivered">>, _attrs, _els}) -> true. encode_xevent_delivered(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:event">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"delivered">>, _attrs, _els}. decode_xevent_offline(__TopXMLNS, __Opts, {xmlel, <<"offline">>, _attrs, _els}) -> true. encode_xevent_offline(true, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"jabber:x:event">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"offline">>, _attrs, _els}. xmpp-1.4.4/src/p1_mucsub.erl0000644000232200023220000003465513610066730016262 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(p1_mucsub). -compile(export_all). do_decode(<<"unsubscribe">>, <<"urn:xmpp:mucsub:0">>, El, Opts) -> decode_muc_unsubscribe(<<"urn:xmpp:mucsub:0">>, Opts, El); do_decode(<<"subscribe">>, <<"urn:xmpp:mucsub:0">>, El, Opts) -> decode_muc_subscribe(<<"urn:xmpp:mucsub:0">>, Opts, El); do_decode(<<"event">>, <<"urn:xmpp:mucsub:0">>, El, Opts) -> decode_muc_subscribe_event(<<"urn:xmpp:mucsub:0">>, Opts, El); do_decode(<<"subscriptions">>, <<"urn:xmpp:mucsub:0">>, El, Opts) -> decode_muc_subscriptions(<<"urn:xmpp:mucsub:0">>, Opts, El); do_decode(<<"subscription">>, <<"urn:xmpp:mucsub:0">>, El, Opts) -> decode_muc_subscription(<<"urn:xmpp:mucsub:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"unsubscribe">>, <<"urn:xmpp:mucsub:0">>}, {<<"subscribe">>, <<"urn:xmpp:mucsub:0">>}, {<<"event">>, <<"urn:xmpp:mucsub:0">>}, {<<"subscriptions">>, <<"urn:xmpp:mucsub:0">>}, {<<"subscription">>, <<"urn:xmpp:mucsub:0">>}]. do_encode({muc_subscription, _, _, _} = Subscription, TopXMLNS) -> encode_muc_subscription(Subscription, TopXMLNS); do_encode({muc_subscriptions, _} = Subscriptions, TopXMLNS) -> encode_muc_subscriptions(Subscriptions, TopXMLNS); do_encode({muc_subscribe, _, _, _, _} = Subscribe, TopXMLNS) -> encode_muc_subscribe(Subscribe, TopXMLNS); do_encode({muc_unsubscribe, _, _} = Unsubscribe, TopXMLNS) -> encode_muc_unsubscribe(Unsubscribe, TopXMLNS). do_get_name({muc_subscribe, _, _, _, _}) -> <<"subscribe">>; do_get_name({muc_subscription, _, _, _}) -> <<"subscription">>; do_get_name({muc_subscriptions, _}) -> <<"subscriptions">>; do_get_name({muc_unsubscribe, _, _}) -> <<"unsubscribe">>. do_get_ns({muc_subscribe, _, _, _, _}) -> <<"urn:xmpp:mucsub:0">>; do_get_ns({muc_subscription, _, _, _}) -> <<"urn:xmpp:mucsub:0">>; do_get_ns({muc_subscriptions, _}) -> <<"urn:xmpp:mucsub:0">>; do_get_ns({muc_unsubscribe, _, _}) -> <<"urn:xmpp:mucsub:0">>. pp(muc_subscription, 3) -> [jid, nick, events]; pp(muc_subscriptions, 1) -> [list]; pp(muc_subscribe, 4) -> [nick, password, jid, events]; pp(muc_unsubscribe, 2) -> [nick, jid]; pp(_, _) -> no. records() -> [{muc_subscription, 3}, {muc_subscriptions, 1}, {muc_subscribe, 4}, {muc_unsubscribe, 2}]. decode_muc_unsubscribe(__TopXMLNS, __Opts, {xmlel, <<"unsubscribe">>, _attrs, _els}) -> {Nick, Jid} = decode_muc_unsubscribe_attrs(__TopXMLNS, _attrs, undefined, undefined), {muc_unsubscribe, Nick, Jid}. decode_muc_unsubscribe_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], _Nick, Jid) -> decode_muc_unsubscribe_attrs(__TopXMLNS, _attrs, _val, Jid); decode_muc_unsubscribe_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Nick, _Jid) -> decode_muc_unsubscribe_attrs(__TopXMLNS, _attrs, Nick, _val); decode_muc_unsubscribe_attrs(__TopXMLNS, [_ | _attrs], Nick, Jid) -> decode_muc_unsubscribe_attrs(__TopXMLNS, _attrs, Nick, Jid); decode_muc_unsubscribe_attrs(__TopXMLNS, [], Nick, Jid) -> {decode_muc_unsubscribe_attr_nick(__TopXMLNS, Nick), decode_muc_unsubscribe_attr_jid(__TopXMLNS, Jid)}. encode_muc_unsubscribe({muc_unsubscribe, Nick, Jid}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mucsub:0">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_unsubscribe_attr_jid(Jid, encode_muc_unsubscribe_attr_nick(Nick, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"unsubscribe">>, _attrs, _els}. decode_muc_unsubscribe_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_muc_unsubscribe_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_unsubscribe_attr_nick(<<>>, _acc) -> _acc; encode_muc_unsubscribe_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_muc_unsubscribe_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_unsubscribe_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"unsubscribe">>, __TopXMLNS}}); _res -> _res end. encode_muc_unsubscribe_attr_jid(undefined, _acc) -> _acc; encode_muc_unsubscribe_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_subscribe(__TopXMLNS, __Opts, {xmlel, <<"subscribe">>, _attrs, _els}) -> Events = decode_muc_subscribe_els(__TopXMLNS, __Opts, _els, []), {Nick, Password, Jid} = decode_muc_subscribe_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {muc_subscribe, Nick, Password, Jid, Events}. decode_muc_subscribe_els(__TopXMLNS, __Opts, [], Events) -> lists:reverse(Events); decode_muc_subscribe_els(__TopXMLNS, __Opts, [{xmlel, <<"event">>, _attrs, _} = _el | _els], Events) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mucsub:0">> -> decode_muc_subscribe_els(__TopXMLNS, __Opts, _els, [decode_muc_subscribe_event(<<"urn:xmpp:mucsub:0">>, __Opts, _el) | Events]); _ -> decode_muc_subscribe_els(__TopXMLNS, __Opts, _els, Events) end; decode_muc_subscribe_els(__TopXMLNS, __Opts, [_ | _els], Events) -> decode_muc_subscribe_els(__TopXMLNS, __Opts, _els, Events). decode_muc_subscribe_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], _Nick, Password, Jid) -> decode_muc_subscribe_attrs(__TopXMLNS, _attrs, _val, Password, Jid); decode_muc_subscribe_attrs(__TopXMLNS, [{<<"password">>, _val} | _attrs], Nick, _Password, Jid) -> decode_muc_subscribe_attrs(__TopXMLNS, _attrs, Nick, _val, Jid); decode_muc_subscribe_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], Nick, Password, _Jid) -> decode_muc_subscribe_attrs(__TopXMLNS, _attrs, Nick, Password, _val); decode_muc_subscribe_attrs(__TopXMLNS, [_ | _attrs], Nick, Password, Jid) -> decode_muc_subscribe_attrs(__TopXMLNS, _attrs, Nick, Password, Jid); decode_muc_subscribe_attrs(__TopXMLNS, [], Nick, Password, Jid) -> {decode_muc_subscribe_attr_nick(__TopXMLNS, Nick), decode_muc_subscribe_attr_password(__TopXMLNS, Password), decode_muc_subscribe_attr_jid(__TopXMLNS, Jid)}. encode_muc_subscribe({muc_subscribe, Nick, Password, Jid, Events}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mucsub:0">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_subscribe_$events'(Events, __NewTopXMLNS, [])), _attrs = encode_muc_subscribe_attr_jid(Jid, encode_muc_subscribe_attr_password(Password, encode_muc_subscribe_attr_nick(Nick, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"subscribe">>, _attrs, _els}. 'encode_muc_subscribe_$events'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_subscribe_$events'([Events | _els], __TopXMLNS, _acc) -> 'encode_muc_subscribe_$events'(_els, __TopXMLNS, [encode_muc_subscribe_event(Events, __TopXMLNS) | _acc]). decode_muc_subscribe_attr_nick(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"nick">>, <<"subscribe">>, __TopXMLNS}}); decode_muc_subscribe_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_subscribe_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. decode_muc_subscribe_attr_password(__TopXMLNS, undefined) -> <<>>; decode_muc_subscribe_attr_password(__TopXMLNS, _val) -> _val. encode_muc_subscribe_attr_password(<<>>, _acc) -> _acc; encode_muc_subscribe_attr_password(_val, _acc) -> [{<<"password">>, _val} | _acc]. decode_muc_subscribe_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_subscribe_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"subscribe">>, __TopXMLNS}}); _res -> _res end. encode_muc_subscribe_attr_jid(undefined, _acc) -> _acc; encode_muc_subscribe_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_subscribe_event(__TopXMLNS, __Opts, {xmlel, <<"event">>, _attrs, _els}) -> Node = decode_muc_subscribe_event_attrs(__TopXMLNS, _attrs, undefined), Node. decode_muc_subscribe_event_attrs(__TopXMLNS, [{<<"node">>, _val} | _attrs], _Node) -> decode_muc_subscribe_event_attrs(__TopXMLNS, _attrs, _val); decode_muc_subscribe_event_attrs(__TopXMLNS, [_ | _attrs], Node) -> decode_muc_subscribe_event_attrs(__TopXMLNS, _attrs, Node); decode_muc_subscribe_event_attrs(__TopXMLNS, [], Node) -> decode_muc_subscribe_event_attr_node(__TopXMLNS, Node). encode_muc_subscribe_event(Node, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mucsub:0">>, [], __TopXMLNS), _els = [], _attrs = encode_muc_subscribe_event_attr_node(Node, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"event">>, _attrs, _els}. decode_muc_subscribe_event_attr_node(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"node">>, <<"event">>, __TopXMLNS}}); decode_muc_subscribe_event_attr_node(__TopXMLNS, _val) -> _val. encode_muc_subscribe_event_attr_node(_val, _acc) -> [{<<"node">>, _val} | _acc]. decode_muc_subscriptions(__TopXMLNS, __Opts, {xmlel, <<"subscriptions">>, _attrs, _els}) -> List = decode_muc_subscriptions_els(__TopXMLNS, __Opts, _els, []), {muc_subscriptions, List}. decode_muc_subscriptions_els(__TopXMLNS, __Opts, [], List) -> lists:reverse(List); decode_muc_subscriptions_els(__TopXMLNS, __Opts, [{xmlel, <<"subscription">>, _attrs, _} = _el | _els], List) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mucsub:0">> -> decode_muc_subscriptions_els(__TopXMLNS, __Opts, _els, [decode_muc_subscription(<<"urn:xmpp:mucsub:0">>, __Opts, _el) | List]); _ -> decode_muc_subscriptions_els(__TopXMLNS, __Opts, _els, List) end; decode_muc_subscriptions_els(__TopXMLNS, __Opts, [_ | _els], List) -> decode_muc_subscriptions_els(__TopXMLNS, __Opts, _els, List). encode_muc_subscriptions({muc_subscriptions, List}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mucsub:0">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_subscriptions_$list'(List, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"subscriptions">>, _attrs, _els}. 'encode_muc_subscriptions_$list'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_subscriptions_$list'([List | _els], __TopXMLNS, _acc) -> 'encode_muc_subscriptions_$list'(_els, __TopXMLNS, [encode_muc_subscription(List, __TopXMLNS) | _acc]). decode_muc_subscription(__TopXMLNS, __Opts, {xmlel, <<"subscription">>, _attrs, _els}) -> Events = decode_muc_subscription_els(__TopXMLNS, __Opts, _els, []), {Jid, Nick} = decode_muc_subscription_attrs(__TopXMLNS, _attrs, undefined, undefined), {muc_subscription, Jid, Nick, Events}. decode_muc_subscription_els(__TopXMLNS, __Opts, [], Events) -> lists:reverse(Events); decode_muc_subscription_els(__TopXMLNS, __Opts, [{xmlel, <<"event">>, _attrs, _} = _el | _els], Events) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mucsub:0">> -> decode_muc_subscription_els(__TopXMLNS, __Opts, _els, [decode_muc_subscribe_event(<<"urn:xmpp:mucsub:0">>, __Opts, _el) | Events]); _ -> decode_muc_subscription_els(__TopXMLNS, __Opts, _els, Events) end; decode_muc_subscription_els(__TopXMLNS, __Opts, [_ | _els], Events) -> decode_muc_subscription_els(__TopXMLNS, __Opts, _els, Events). decode_muc_subscription_attrs(__TopXMLNS, [{<<"jid">>, _val} | _attrs], _Jid, Nick) -> decode_muc_subscription_attrs(__TopXMLNS, _attrs, _val, Nick); decode_muc_subscription_attrs(__TopXMLNS, [{<<"nick">>, _val} | _attrs], Jid, _Nick) -> decode_muc_subscription_attrs(__TopXMLNS, _attrs, Jid, _val); decode_muc_subscription_attrs(__TopXMLNS, [_ | _attrs], Jid, Nick) -> decode_muc_subscription_attrs(__TopXMLNS, _attrs, Jid, Nick); decode_muc_subscription_attrs(__TopXMLNS, [], Jid, Nick) -> {decode_muc_subscription_attr_jid(__TopXMLNS, Jid), decode_muc_subscription_attr_nick(__TopXMLNS, Nick)}. encode_muc_subscription({muc_subscription, Jid, Nick, Events}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mucsub:0">>, [], __TopXMLNS), _els = lists:reverse('encode_muc_subscription_$events'(Events, __NewTopXMLNS, [])), _attrs = encode_muc_subscription_attr_nick(Nick, encode_muc_subscription_attr_jid(Jid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"subscription">>, _attrs, _els}. 'encode_muc_subscription_$events'([], __TopXMLNS, _acc) -> _acc; 'encode_muc_subscription_$events'([Events | _els], __TopXMLNS, _acc) -> 'encode_muc_subscription_$events'(_els, __TopXMLNS, [encode_muc_subscribe_event(Events, __TopXMLNS) | _acc]). decode_muc_subscription_attr_jid(__TopXMLNS, undefined) -> undefined; decode_muc_subscription_attr_jid(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"jid">>, <<"subscription">>, __TopXMLNS}}); _res -> _res end. encode_muc_subscription_attr_jid(undefined, _acc) -> _acc; encode_muc_subscription_attr_jid(_val, _acc) -> [{<<"jid">>, jid:encode(_val)} | _acc]. decode_muc_subscription_attr_nick(__TopXMLNS, undefined) -> <<>>; decode_muc_subscription_attr_nick(__TopXMLNS, _val) -> _val. encode_muc_subscription_attr_nick(<<>>, _acc) -> _acc; encode_muc_subscription_attr_nick(_val, _acc) -> [{<<"nick">>, _val} | _acc]. xmpp-1.4.4/src/xep0352.erl0000644000232200023220000000505213610066730015457 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0352). -compile(export_all). do_decode(<<"inactive">>, <<"urn:xmpp:csi:0">>, El, Opts) -> decode_csi_inactive(<<"urn:xmpp:csi:0">>, Opts, El); do_decode(<<"active">>, <<"urn:xmpp:csi:0">>, El, Opts) -> decode_csi_active(<<"urn:xmpp:csi:0">>, Opts, El); do_decode(<<"csi">>, <<"urn:xmpp:csi:0">>, El, Opts) -> decode_feature_csi(<<"urn:xmpp:csi:0">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"inactive">>, <<"urn:xmpp:csi:0">>}, {<<"active">>, <<"urn:xmpp:csi:0">>}, {<<"csi">>, <<"urn:xmpp:csi:0">>}]. do_encode({feature_csi} = Csi, TopXMLNS) -> encode_feature_csi(Csi, TopXMLNS); do_encode({csi, active} = Active, TopXMLNS) -> encode_csi_active(Active, TopXMLNS); do_encode({csi, inactive} = Inactive, TopXMLNS) -> encode_csi_inactive(Inactive, TopXMLNS). do_get_name({csi, active}) -> <<"active">>; do_get_name({csi, inactive}) -> <<"inactive">>; do_get_name({feature_csi}) -> <<"csi">>. do_get_ns({csi, active}) -> <<"urn:xmpp:csi:0">>; do_get_ns({csi, inactive}) -> <<"urn:xmpp:csi:0">>; do_get_ns({feature_csi}) -> <<"urn:xmpp:csi:0">>. pp(feature_csi, 0) -> []; pp(csi, 1) -> [type]; pp(_, _) -> no. records() -> [{feature_csi, 0}, {csi, 1}]. decode_csi_inactive(__TopXMLNS, __Opts, {xmlel, <<"inactive">>, _attrs, _els}) -> {csi, inactive}. encode_csi_inactive({csi, inactive}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:csi:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"inactive">>, _attrs, _els}. decode_csi_active(__TopXMLNS, __Opts, {xmlel, <<"active">>, _attrs, _els}) -> {csi, active}. encode_csi_active({csi, active}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:csi:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"active">>, _attrs, _els}. decode_feature_csi(__TopXMLNS, __Opts, {xmlel, <<"csi">>, _attrs, _els}) -> {feature_csi}. encode_feature_csi({feature_csi}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:csi:0">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"csi">>, _attrs, _els}. xmpp-1.4.4/src/xep0356.erl0000644000232200023220000001412613610066730015465 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0356). -compile(export_all). do_decode(<<"privilege">>, <<"urn:xmpp:privilege:1">>, El, Opts) -> decode_privilege(<<"urn:xmpp:privilege:1">>, Opts, El); do_decode(<<"perm">>, <<"urn:xmpp:privilege:1">>, El, Opts) -> decode_privilege_perm(<<"urn:xmpp:privilege:1">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"privilege">>, <<"urn:xmpp:privilege:1">>}, {<<"perm">>, <<"urn:xmpp:privilege:1">>}]. do_encode({privilege_perm, _, _} = Perm, TopXMLNS) -> encode_privilege_perm(Perm, TopXMLNS); do_encode({privilege, _, _} = Privilege, TopXMLNS) -> encode_privilege(Privilege, TopXMLNS). do_get_name({privilege, _, _}) -> <<"privilege">>; do_get_name({privilege_perm, _, _}) -> <<"perm">>. do_get_ns({privilege, _, _}) -> <<"urn:xmpp:privilege:1">>; do_get_ns({privilege_perm, _, _}) -> <<"urn:xmpp:privilege:1">>. pp(privilege_perm, 2) -> [access, type]; pp(privilege, 2) -> [perms, forwarded]; pp(_, _) -> no. records() -> [{privilege_perm, 2}, {privilege, 2}]. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). decode_privilege(__TopXMLNS, __Opts, {xmlel, <<"privilege">>, _attrs, _els}) -> {Perms, Forwarded} = decode_privilege_els(__TopXMLNS, __Opts, _els, [], undefined), {privilege, Perms, Forwarded}. decode_privilege_els(__TopXMLNS, __Opts, [], Perms, Forwarded) -> {lists:reverse(Perms), Forwarded}; decode_privilege_els(__TopXMLNS, __Opts, [{xmlel, <<"perm">>, _attrs, _} = _el | _els], Perms, Forwarded) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:privilege:1">> -> decode_privilege_els(__TopXMLNS, __Opts, _els, [decode_privilege_perm(<<"urn:xmpp:privilege:1">>, __Opts, _el) | Perms], Forwarded); _ -> decode_privilege_els(__TopXMLNS, __Opts, _els, Perms, Forwarded) end; decode_privilege_els(__TopXMLNS, __Opts, [{xmlel, <<"forwarded">>, _attrs, _} = _el | _els], Perms, Forwarded) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:forward:0">> -> decode_privilege_els(__TopXMLNS, __Opts, _els, Perms, xep0297:decode_forwarded(<<"urn:xmpp:forward:0">>, __Opts, _el)); _ -> decode_privilege_els(__TopXMLNS, __Opts, _els, Perms, Forwarded) end; decode_privilege_els(__TopXMLNS, __Opts, [_ | _els], Perms, Forwarded) -> decode_privilege_els(__TopXMLNS, __Opts, _els, Perms, Forwarded). encode_privilege({privilege, Perms, Forwarded}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:privilege:1">>, [], __TopXMLNS), _els = lists:reverse('encode_privilege_$perms'(Perms, __NewTopXMLNS, 'encode_privilege_$forwarded'(Forwarded, __NewTopXMLNS, []))), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"privilege">>, _attrs, _els}. 'encode_privilege_$perms'([], __TopXMLNS, _acc) -> _acc; 'encode_privilege_$perms'([Perms | _els], __TopXMLNS, _acc) -> 'encode_privilege_$perms'(_els, __TopXMLNS, [encode_privilege_perm(Perms, __TopXMLNS) | _acc]). 'encode_privilege_$forwarded'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_privilege_$forwarded'(Forwarded, __TopXMLNS, _acc) -> [xep0297:encode_forwarded(Forwarded, __TopXMLNS) | _acc]. decode_privilege_perm(__TopXMLNS, __Opts, {xmlel, <<"perm">>, _attrs, _els}) -> {Access, Type} = decode_privilege_perm_attrs(__TopXMLNS, _attrs, undefined, undefined), {privilege_perm, Access, Type}. decode_privilege_perm_attrs(__TopXMLNS, [{<<"access">>, _val} | _attrs], _Access, Type) -> decode_privilege_perm_attrs(__TopXMLNS, _attrs, _val, Type); decode_privilege_perm_attrs(__TopXMLNS, [{<<"type">>, _val} | _attrs], Access, _Type) -> decode_privilege_perm_attrs(__TopXMLNS, _attrs, Access, _val); decode_privilege_perm_attrs(__TopXMLNS, [_ | _attrs], Access, Type) -> decode_privilege_perm_attrs(__TopXMLNS, _attrs, Access, Type); decode_privilege_perm_attrs(__TopXMLNS, [], Access, Type) -> {decode_privilege_perm_attr_access(__TopXMLNS, Access), decode_privilege_perm_attr_type(__TopXMLNS, Type)}. encode_privilege_perm({privilege_perm, Access, Type}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:privilege:1">>, [], __TopXMLNS), _els = [], _attrs = encode_privilege_perm_attr_type(Type, encode_privilege_perm_attr_access(Access, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"perm">>, _attrs, _els}. decode_privilege_perm_attr_access(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"access">>, <<"perm">>, __TopXMLNS}}); decode_privilege_perm_attr_access(__TopXMLNS, _val) -> case catch dec_enum(_val, [roster, message, presence]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"access">>, <<"perm">>, __TopXMLNS}}); _res -> _res end. encode_privilege_perm_attr_access(_val, _acc) -> [{<<"access">>, enc_enum(_val)} | _acc]. decode_privilege_perm_attr_type(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"type">>, <<"perm">>, __TopXMLNS}}); decode_privilege_perm_attr_type(__TopXMLNS, _val) -> case catch dec_enum(_val, [none, get, set, both, outgoing, roster, managed_entity]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"type">>, <<"perm">>, __TopXMLNS}}); _res -> _res end. encode_privilege_perm_attr_type(_val, _acc) -> [{<<"type">>, enc_enum(_val)} | _acc]. xmpp-1.4.4/src/xmpp_codec.erl0000644000232200023220000016604713610066730016506 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xmpp_codec). -compile(export_all). decode(El) -> decode(El, <<>>, []). decode(El, Opts) -> decode(El, <<>>, Opts). decode({xmlel, Name, Attrs, _} = El, TopXMLNS, Opts) -> XMLNS = get_attr(<<"xmlns">>, Attrs, TopXMLNS), case get_mod(Name, XMLNS) of undefined when XMLNS == <<>> -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); undefined -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}); Mod -> Mod:do_decode(Name, XMLNS, El, Opts) end. encode(El) -> encode(El, <<>>). encode({xmlel, _, _, _} = El, _) -> El; encode({xmlcdata, _} = CData, _) -> CData; encode(El, TopXMLNS) -> Mod = get_mod(El), Mod:do_encode(El, TopXMLNS). get_name(El) -> Mod = get_mod(El), Mod:do_get_name(El). get_ns(El) -> Mod = get_mod(El), Mod:do_get_ns(El). is_known_tag({xmlel, Name, Attrs, _}, TopXMLNS) -> XMLNS = get_attr(<<"xmlns">>, Attrs, TopXMLNS), get_mod(Name, XMLNS) /= undefined. get_els(Term) -> Mod = get_mod(Term), Mod:get_els(Term). set_els(Term, Els) -> Mod = get_mod(Term), Mod:set_els(Term, Els). do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> []. register_module(Mod) -> register_module(Mod, xmpp_codec_external). unregister_module(Mod) -> unregister_module(Mod, xmpp_codec_external). format_error({bad_attr_value, Attr, Tag, XMLNS}) -> <<"Bad value of attribute '", Attr/binary, "' in tag <", Tag/binary, "/> qualified by namespace '", XMLNS/binary, "'">>; format_error({bad_cdata_value, <<>>, Tag, XMLNS}) -> <<"Bad value of cdata in tag <", Tag/binary, "/> qualified by namespace '", XMLNS/binary, "'">>; format_error({missing_tag, Tag, XMLNS}) -> <<"Missing tag <", Tag/binary, "/> qualified by namespace '", XMLNS/binary, "'">>; format_error({missing_attr, Attr, Tag, XMLNS}) -> <<"Missing attribute '", Attr/binary, "' in tag <", Tag/binary, "/> qualified by namespace '", XMLNS/binary, "'">>; format_error({missing_cdata, <<>>, Tag, XMLNS}) -> <<"Missing cdata in tag <", Tag/binary, "/> qualified by namespace '", XMLNS/binary, "'">>; format_error({unknown_tag, Tag, XMLNS}) -> <<"Unknown tag <", Tag/binary, "/> qualified by namespace '", XMLNS/binary, "'">>; format_error({missing_tag_xmlns, Tag}) -> <<"Missing namespace for tag <", Tag/binary, "/>">>. io_format_error({bad_attr_value, Attr, Tag, XMLNS}) -> {<<"Bad value of attribute '~s' in tag <~s/> " "qualified by namespace '~s'">>, [Attr, Tag, XMLNS]}; io_format_error({bad_cdata_value, <<>>, Tag, XMLNS}) -> {<<"Bad value of cdata in tag <~s/> qualified " "by namespace '~s'">>, [Tag, XMLNS]}; io_format_error({missing_tag, Tag, XMLNS}) -> {<<"Missing tag <~s/> qualified by namespace " "'~s'">>, [Tag, XMLNS]}; io_format_error({missing_attr, Attr, Tag, XMLNS}) -> {<<"Missing attribute '~s' in tag <~s/> " "qualified by namespace '~s'">>, [Attr, Tag, XMLNS]}; io_format_error({missing_cdata, <<>>, Tag, XMLNS}) -> {<<"Missing cdata in tag <~s/> qualified " "by namespace '~s'">>, [Tag, XMLNS]}; io_format_error({unknown_tag, Tag, XMLNS}) -> {<<"Unknown tag <~s/> qualified by namespace " "'~s'">>, [Tag, XMLNS]}; io_format_error({missing_tag_xmlns, Tag}) -> {<<"Missing namespace for tag <~s/>">>, [Tag]}. get_attr(Attr, Attrs, Default) -> case lists:keyfind(Attr, 1, Attrs) of {_, Val} -> Val; false -> Default end. enc_xmlns_attrs(XMLNS, XMLNS) -> []; enc_xmlns_attrs(XMLNS, _) -> [{<<"xmlns">>, XMLNS}]. choose_top_xmlns(<<>>, NSList, TopXMLNS) -> case lists:member(TopXMLNS, NSList) of true -> TopXMLNS; false -> hd(NSList) end; choose_top_xmlns(XMLNS, _, _) -> XMLNS. register_module(Mod, ResolverMod) -> MD5Sum = try Mod:module_info(md5) of Val -> Val catch error:badarg -> {ok, {Mod, Val}} = beam_lib:md5(code:which(Mod)), Val end, case orddict:find(Mod, ResolverMod:modules()) of {ok, MD5Sum} -> ok; _ -> Mods = orddict:store(Mod, MD5Sum, ResolverMod:modules()), recompile_resolver(Mods, ResolverMod) end. unregister_module(Mod, ResolverMod) -> case orddict:find(Mod, ResolverMod:modules()) of {ok, _} -> Mods = orddict:erase(Mod, ResolverMod:modules()), recompile_resolver(Mods, ResolverMod); error -> ok end. recompile_resolver(Mods, ResolverMod) -> Tags = lists:flatmap(fun (M) -> [{Name, XMLNS, M} || {Name, XMLNS} <- M:tags()] end, orddict:fetch_keys(Mods)), Records = lists:flatmap(fun (M) -> [{RecName, RecSize, M} || {RecName, RecSize} <- M:records()] end, orddict:fetch_keys(Mods)), Lookup1 = string:join(lists:map(fun ({RecName, RecSize, M}) -> io_lib:format("lookup({~s}) -> '~s'", [string:join([io_lib:format("'~s'", [RecName]) | ["_" || _ <- lists:seq(1, RecSize)]], ","), M]) end, Records) ++ ["lookup(Term) -> erlang:error(badarg, " "[Term])."], ";" ++ io_lib:nl()), Lookup2 = string:join(lists:map(fun ({Name, XMLNS, M}) -> io_lib:format("lookup(~w, ~w) -> '~s'", [Name, XMLNS, M]) end, Tags) ++ ["lookup(_, _) -> undefined."], ";" ++ io_lib:nl()), Modules = io_lib:format("modules() -> [~s].", [string:join([io_lib:format("{'~s', ~w}", [M, S]) || {M, S} <- Mods], ",")]), Module = io_lib:format("-module(~s).", [ResolverMod]), Compile = "-compile(export_all).", Forms = lists:map(fun (Expr) -> {ok, Tokens, _} = erl_scan:string(lists:flatten(Expr)), {ok, Form} = erl_parse:parse_form(Tokens), Form end, [Module, Compile, Modules, Lookup1, Lookup2]), {ok, Code} = case compile:forms(Forms, []) of {ok, ResolverMod, Bin} -> {ok, Bin}; {ok, ResolverMod, Bin, _Warnings} -> {ok, Bin}; Error -> Error end, {module, ResolverMod} = code:load_binary(ResolverMod, "nofile", Code), ok. pp(xmlel, 3) -> [name, attrs, children]; pp(Name, Arity) -> try get_mod(erlang:make_tuple(Arity + 1, undefined, [{1, Name}])) of Mod -> Mod:pp(Name, Arity) catch error:badarg -> no end. records() -> []. get_mod(<<"report">>, <<"urn:xmpp:reporting:0">>) -> xep0377; get_mod(<<"status">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"priority">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"item-not-found">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"failure">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>) -> rfc6120; get_mod(<<"max-items-exceeded">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"x">>, <<"jabber:x:conference">>) -> xep0249; get_mod(<<"jid">>, <<"urn:xmpp:mam:1">>) -> xep0313; get_mod(<<"never">>, <<"urn:xmpp:mam:0">>) -> xep0313; get_mod(<<"tie-break">>, <<"urn:xmpp:jingle:errors:1">>) -> xep0166; get_mod(<<"item">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"decline">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"x">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"x509-challenge">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"failure">>, <<"http://jabber.org/protocol/compress">>) -> xep0138; get_mod(<<"resource-constraint">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"unsupported-version">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"stream:error">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"VERSION">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"SORT-STRING">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"item-forbidden">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"history">>, <<"http://jabber.org/protocol/muc">>) -> xep0045; get_mod(<<"actor">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"last">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"inactive">>, <<"urn:xmpp:csi:0">>) -> xep0352; get_mod(<<"message">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"presence">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"configuration-required">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"INTL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"item">>, <<"http://jabber.org/protocol/muc#admin">>) -> xep0045; get_mod(<<"gone">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"range">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"error">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"password">>, <<"jabber:iq:auth">>) -> xep0078; get_mod(<<"TZ">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"request">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"timeout">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"content">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"nick">>, <<"storage:bookmarks">>) -> xep0048; get_mod(<<"iq">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"setup-failed">>, <<"http://jabber.org/protocol/compress">>) -> xep0138; get_mod(<<"query">>, <<"http://jabber.org/protocol/muc#admin">>) -> xep0045; get_mod(<<"thumbnail">>, <<"urn:xmpp:thumbs:1">>) -> xep0264; get_mod(<<"security-required">>, <<"urn:xmpp:jingle:errors:1">>) -> xep0166; get_mod(<<"url">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"GIVEN">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"TYPE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"subscribe">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"query">>, <<"http://jabber.org/protocol/disco#items">>) -> xep0030; get_mod(<<"first">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"x">>, <<"http://jabber.org/protocol/muc">>) -> xep0045; get_mod(<<"media">>, <<"urn:xmpp:media-element">>) -> xep0221; get_mod(<<"out-of-order">>, <<"urn:xmpp:jingle:errors:1">>) -> xep0166; get_mod(<<"KEYWORD">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"result">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"active">>, <<"urn:xmpp:csi:0">>) -> xep0352; get_mod(<<"slot">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"data">>, <<"http://jabber.org/protocol/ibb">>) -> xep0047; get_mod(<<"query">>, <<"jabber:iq:roster">>) -> rfc6121; get_mod(<<"digest">>, <<"jabber:iq:auth">>) -> xep0078; get_mod(<<"NUMBER">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"notification">>, <<"urn:xmpp:push:0">>) -> xep0357; get_mod(<<"gone">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"response">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"REGION">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"create">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"offline">>, <<"http://jabber.org/protocol/offline">>) -> xep0013; get_mod(<<"actions">>, <<"http://jabber.org/protocol/commands">>) -> xep0050; get_mod(<<"thread">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"bad-protocol">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"mechanisms">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"query">>, <<"http://jabber.org/protocol/bytestreams">>) -> xep0065; get_mod(<<"displayed">>, <<"jabber:x:event">>) -> xep0022; get_mod(<<"start">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"received">>, <<"urn:xmpp:carbons:2">>) -> xep0280; get_mod(<<"x">>, <<"jabber:x:event">>) -> xep0022; get_mod(<<"general-error">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"nick">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"internal-server-error">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"x">>, <<"vcard-temp:x:update">>) -> xep0153; get_mod(<<"purge">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"with">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"address">>, <<"urn:xmpp:sic:0">>) -> xep0279; get_mod(<<"put">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"failure">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"PRIVATE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"options">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"pubsub">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"disable">>, <<"urn:xmpp:carbons:2">>) -> xep0280; get_mod(<<"unsupported-method">>, <<"http://jabber.org/protocol/compress">>) -> xep0138; get_mod(<<"tzo">>, <<"urn:xmpp:time">>) -> xep0202; get_mod(<<"POSTAL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"payload-too-big">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"presence-out">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"mechanism-too-weak">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"improper-addressing">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"r">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"submission-id">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"unsupported-info">>, <<"urn:xmpp:jingle:errors:1">>) -> xep0166; get_mod(<<"query">>, <<"jabber:iq:version">>) -> xep0092; get_mod(<<"archived">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"next">>, <<"http://jabber.org/protocol/commands">>) -> xep0050; get_mod(<<"x509-signature">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"subscription">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"subscriptions">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"prefs">>, <<"urn:xmpp:mam:1">>) -> xep0313; get_mod(<<"sm">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"item">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"feature-not-implemented">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"subscription-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"resource">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>) -> rfc6120; get_mod(<<"compressed">>, <<"http://jabber.org/protocol/compress">>) -> xep0138; get_mod(<<"instructions">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"idle">>, <<"urn:xmpp:idle:1">>) -> xep0319; get_mod(<<"retract">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"subscriptions">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"max-nodes-exceeded">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"delay">>, <<"urn:xmpp:delay">>) -> xep0203; get_mod(<<"client-join">>, <<"urn:xmpp:mix:pam:0">>) -> xep0405; get_mod(<<"first">>, <<"jabber:iq:search">>) -> xep0055; get_mod(<<"request">>, <<"urn:xmpp:http:upload:0">>) -> xep0363; get_mod(<<"conflict">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"password">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"city">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"query">>, <<"urn:xmpp:delegation:1">>) -> xep0355; get_mod(<<"hash">>, <<"urn:xmpp:hashes:2">>) -> xep0300; get_mod(<<"invalid-options">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"event">>, <<"urn:xmpp:mucsub:0">>) -> p1_mucsub; get_mod(<<"query">>, <<"jabber:iq:search">>) -> xep0055; get_mod(<<"content-type">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"stream:error">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"field">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"unsubscribe">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"presence">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"configure">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"item">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"x">>, <<"jabber:x:oob">>) -> xep0066; get_mod(<<"delegate">>, <<"urn:xmpp:delegation:1">>) -> xep0355; get_mod(<<"priority">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"configuration">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"create">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"enable">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"no-permanent-storage">>, <<"urn:xmpp:hints">>) -> xep0334; get_mod(<<"unsupported-applications">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"text">>, <<"urn:xmpp:reporting:0">>) -> xep0377; get_mod(<<"credentials-expired">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"processing-failed">>, <<"http://jabber.org/protocol/compress">>) -> xep0138; get_mod(<<"address">>, <<"http://jabber.org/protocol/address">>) -> xep0033; get_mod(<<"unsupported-transports">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"file-not-available">>, <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>) -> xep0234; get_mod(<<"c">>, <<"http://jabber.org/protocol/caps">>) -> xep0115; get_mod(<<"resume">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"size">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"slot">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"get">>, <<"urn:xmpp:http:upload:0">>) -> xep0363; get_mod(<<"pointer">>, <<"urn:xmpp:avatar:metadata">>) -> xep0084; get_mod(<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"compression">>, <<"http://jabber.org/features/compress">>) -> xep0138; get_mod(<<"remove">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"active">>, <<"http://jabber.org/protocol/chatstates">>) -> xep0085; get_mod(<<"invite">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"no-storage">>, <<"urn:xmpp:hints">>) -> xep0334; get_mod(<<"stream:stream">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"data">>, <<"urn:xmpp:bob">>) -> xep0231; get_mod(<<"success">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"method">>, <<"http://jabber.org/protocol/compress">>) -> xep0138; get_mod(<<"x">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"transport">>, <<"urn:xmpp:jingle:transports:s5b:1">>) -> xep0260; get_mod(<<"CONFIDENTIAL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"subscribe">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"media-type">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"stream:features">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"fin">>, <<"urn:xmpp:mam:1">>) -> xep0313; get_mod(<<"enabled">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"max-file-size">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"x509-register">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"resource-constraint">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"BBS">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"always">>, <<"urn:xmpp:mam:1">>) -> xep0313; get_mod(<<"errors">>, <<"urn:xmpp:features:dialback">>) -> xep0220; get_mod(<<"media-error">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"name">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"description">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"checksum">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"host-gone">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"photo">>, <<"vcard-temp:x:update">>) -> xep0153; get_mod(<<"handshake">>, <<"jabber:component:accept">>) -> xep0114; get_mod(<<"not-subscribed">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"size">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"query">>, <<"http://jabber.org/protocol/stats">>) -> xep0039; get_mod(<<"body">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"payment-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"system-shutdown">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"items">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"query">>, <<"urn:xmpp:mam:2">>) -> xep0313; get_mod(<<"prev">>, <<"http://jabber.org/protocol/commands">>) -> xep0050; get_mod(<<"presence-in">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"item">>, <<"urn:xmpp:blocking">>) -> xep0191; get_mod(<<"NICKNAME">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"MAILER">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"EXTVAL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"streamhost">>, <<"http://jabber.org/protocol/bytestreams">>) -> xep0065; get_mod(<<"client-leave">>, <<"urn:xmpp:mix:pam:0">>) -> xep0405; get_mod(<<"mix">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"no-store">>, <<"urn:xmpp:hints">>) -> xep0334; get_mod(<<"nick">>, <<"http://jabber.org/protocol/nick">>) -> xep0172; get_mod(<<"item">>, <<"jabber:iq:roster">>) -> rfc6121; get_mod(<<"redirect">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"a">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"info">>, <<"urn:xmpp:avatar:metadata">>) -> xep0084; get_mod(<<"date">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"not-allowed">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"BINVAL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"nodeid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"email">>, <<"jabber:iq:search">>) -> xep0055; get_mod(<<"filename">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"put">>, <<"urn:xmpp:http:upload:0">>) -> xep0363; get_mod(<<"file-too-large">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"received">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"JABBERID">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"subscription">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"decline">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"key">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"unsupported">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"unsupported-access-model">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"ip">>, <<"urn:xmpp:sic:1">>) -> xep0279; get_mod(<<"attribute">>, <<"urn:xmpp:delegation:1">>) -> xep0355; get_mod(<<"status">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"query">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"CLASS">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"result">>, <<"urn:xmpp:mam:2">>) -> xep0313; get_mod(<<"purge">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"header">>, <<"http://jabber.org/protocol/shim">>) -> xep0131; get_mod(<<"failed">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"x">>, <<"jabber:x:expire">>) -> xep0023; get_mod(<<"max-file-size">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"unknown-session">>, <<"urn:xmpp:jingle:errors:1">>) -> xep0166; get_mod(<<"candidate-used">>, <<"urn:xmpp:jingle:transports:s5b:1">>) -> xep0260; get_mod(<<"not-well-formed">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"content-type">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"perm">>, <<"urn:xmpp:privilege:1">>) -> xep0356; get_mod(<<"close">>, <<"http://jabber.org/protocol/ibb">>) -> xep0047; get_mod(<<"x509-csr">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"internal-server-error">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"service-unavailable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"password">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"jid">>, <<"urn:xmpp:mam:2">>) -> xep0313; get_mod(<<"never">>, <<"urn:xmpp:mam:1">>) -> xep0313; get_mod(<<"metadata">>, <<"urn:xmpp:avatar:metadata">>) -> xep0084; get_mod(<<"x509-cert">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"jid">>, <<"urn:xmpp:jidprep:0">>) -> xep0328; get_mod(<<"password">>, <<"http://jabber.org/protocol/muc#owner">>) -> xep0045; get_mod(<<"method">>, <<"http://jabber.org/features/compress">>) -> xep0138; get_mod(<<"invalid-jid">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"iq">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"LOCALITY">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"inactive">>, <<"http://jabber.org/protocol/chatstates">>) -> xep0085; get_mod(<<"affiliations">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"first">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"get">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"failed-application">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"priority">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"redirect">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"encryption-required">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"stanza-id">>, <<"urn:xmpp:sid:0">>) -> xep0359; get_mod(<<"complete">>, <<"http://jabber.org/protocol/commands">>) -> xep0050; get_mod(<<"enable">>, <<"urn:xmpp:push:0">>) -> xep0357; get_mod(<<"time">>, <<"urn:xmpp:time">>) -> xep0202; get_mod(<<"invalid-namespace">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"PREFIX">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"affiliations">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"desc">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"aborted">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"address">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"LOGO">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"retract">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"destroy">>, <<"http://jabber.org/protocol/muc#owner">>) -> xep0045; get_mod(<<"compress">>, <<"http://jabber.org/protocol/compress">>) -> xep0138; get_mod(<<"ADR">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"continue">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"subscription">>, <<"urn:xmpp:mucsub:0">>) -> p1_mucsub; get_mod(<<"item">>, <<"jabber:iq:search">>) -> xep0055; get_mod(<<"stream:stream">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"proceed">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>) -> rfc6120; get_mod(<<"instructions">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"undefined-condition">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"DESC">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"subscriptions">>, <<"urn:xmpp:mucsub:0">>) -> p1_mucsub; get_mod(<<"resumed">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"slot">>, <<"urn:xmpp:http:upload:0">>) -> xep0363; get_mod(<<"open">>, <<"http://jabber.org/protocol/ibb">>) -> xep0047; get_mod(<<"connectivity-error">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"stream:features">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"request">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"file">>, <<"urn:xmpp:jingle:apps:file-transfer:5">>) -> xep0234; get_mod(<<"query">>, <<"jabber:iq:auth">>) -> xep0078; get_mod(<<"CELL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"stream:stream">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"email">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"event">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"file-too-large">>, <<"urn:xmpp:jingle:apps:file-transfer:errors:0">>) -> xep0234; get_mod(<<"active">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"payload-required">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"destroy">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"address">>, <<"urn:xmpp:sic:1">>) -> xep0279; get_mod(<<"error">>, <<"http://jabber.org/protocol/stats">>) -> xep0039; get_mod(<<"name">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"not-authorized">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"PCS">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"unsubscribe">>, <<"urn:xmpp:mucsub:0">>) -> p1_mucsub; get_mod(<<"failed">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"db:verify">>, <<"jabber:server">>) -> xep0220; get_mod(<<"url">>, <<"jabber:x:oob">>) -> xep0066; get_mod(<<"disable">>, <<"urn:xmpp:push:0">>) -> xep0357; get_mod(<<"delegated">>, <<"urn:xmpp:delegation:1">>) -> xep0355; get_mod(<<"hash-used">>, <<"urn:xmpp:hashes:2">>) -> xep0300; get_mod(<<"security-error">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"presence">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"abort">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"FAMILY">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"URL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"headers">>, <<"http://jabber.org/protocol/shim">>) -> xep0131; get_mod(<<"received">>, <<"urn:xmpp:receipts">>) -> xep0184; get_mod(<<"jid-malformed">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"register">>, <<"http://jabber.org/features/iq-register">>) -> xep0077; get_mod(<<"optional">>, <<"urn:ietf:params:xml:ns:xmpp-session">>) -> rfc3921; get_mod(<<"offline">>, <<"jabber:x:event">>) -> xep0022; get_mod(<<"default">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"bind">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>) -> rfc6120; get_mod(<<"enable">>, <<"urn:xmpp:carbons:2">>) -> xep0280; get_mod(<<"block">>, <<"urn:xmpp:blocking">>) -> xep0191; get_mod(<<"delete">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"prefs">>, <<"urn:xmpp:mam:2">>) -> xep0313; get_mod(<<"sm">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"fetch">>, <<"http://jabber.org/protocol/offline">>) -> xep0013; get_mod(<<"participant">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"failed-transport">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"abuse">>, <<"urn:xmpp:reporting:0">>) -> xep0377; get_mod(<<"state">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"utc">>, <<"urn:xmpp:time">>) -> xep0202; get_mod(<<"DOM">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"default">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"show">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"FAX">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"subscribe">>, <<"urn:xmpp:mucsub:0">>) -> p1_mucsub; get_mod(<<"index">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"csi">>, <<"urn:xmpp:csi:0">>) -> xep0352; get_mod(<<"instructions">>, <<"jabber:iq:search">>) -> xep0055; get_mod(<<"invalid-authzid">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"invalid-id">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"PUBLIC">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"precondition-not-met">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"item">>, <<"http://jabber.org/protocol/offline">>) -> xep0013; get_mod(<<"get">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"query">>, <<"http://jabber.org/protocol/disco#info">>) -> xep0030; get_mod(<<"last">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"thread">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"streamhost-used">>, <<"http://jabber.org/protocol/bytestreams">>) -> xep0065; get_mod(<<"query">>, <<"urn:xmpp:mam:0">>) -> xep0313; get_mod(<<"recipient-unavailable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"ISDN">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"GEO">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"delivered">>, <<"jabber:x:event">>) -> xep0022; get_mod(<<"x509-cert-chain">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"iq">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"message">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"resource">>, <<"jabber:iq:auth">>) -> xep0078; get_mod(<<"success">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"item">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"store">>, <<"urn:xmpp:hints">>) -> xep0334; get_mod(<<"unblock">>, <<"urn:xmpp:blocking">>) -> xep0191; get_mod(<<"query">>, <<"jabber:iq:private">>) -> xep0049; get_mod(<<"invalid-xml">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"PCODE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"LAT">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"never">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"enable">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"size">>, <<"eu:siacs:conversations:http:upload">>) -> xep0363; get_mod(<<"registration-required">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"remote-connection-failed">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"pending-subscription">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"misc">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"policy-violation">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"USERID">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"resume">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"purge">>, <<"http://jabber.org/protocol/offline">>) -> xep0013; get_mod(<<"MODEM">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"ORGUNIT">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"UID">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"required">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"result">>, <<"urn:xmpp:mam:0">>) -> xep0313; get_mod(<<"x509-challenge-failed">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"TEL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"prefs">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"captcha">>, <<"urn:xmpp:captcha">>) -> xep0158; get_mod(<<"identity">>, <<"http://jabber.org/protocol/disco#info">>) -> xep0030; get_mod(<<"text">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"private">>, <<"urn:xmpp:carbons:2">>) -> xep0280; get_mod(<<"privilege">>, <<"urn:xmpp:privilege:1">>) -> xep0356; get_mod(<<"spam">>, <<"urn:xmpp:reporting:0">>) -> xep0377; get_mod(<<"show">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"PAGER">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"MSG">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"PHONETIC">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"jid">>, <<"urn:xmpp:mam:0">>) -> xep0313; get_mod(<<"fin">>, <<"urn:xmpp:mam:2">>) -> xep0313; get_mod(<<"ver">>, <<"urn:xmpp:features:rosterver">>) -> rfc6121; get_mod(<<"body">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"always">>, <<"urn:xmpp:mam:2">>) -> xep0313; get_mod(<<"join">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"composing">>, <<"jabber:x:event">>) -> xep0022; get_mod(<<"reset">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"FN">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"BDAY">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"ROLE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"composing">>, <<"http://jabber.org/protocol/chatstates">>) -> xep0085; get_mod(<<"unique">>, <<"http://jabber.org/protocol/muc#unique">>) -> xep0045; get_mod(<<"after">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"query">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"x509-revoke">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"account-disabled">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"EMAIL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"jid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"subid-required">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"value">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"invalid-subid">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"not-in-roster-group">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"unsupported-encoding">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"stream:error">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"subject">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"LON">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"name">>, <<"jabber:iq:version">>) -> xep0092; get_mod(<<"blocklist">>, <<"urn:xmpp:blocking">>) -> xep0191; get_mod(<<"see-other-host">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"WORK">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"presence-subscription-required">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"continue">>, <<"http://jabber.org/protocol/muc#admin">>) -> xep0045; get_mod(<<"undefined-condition">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"error">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"SOUND">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"actor">>, <<"http://jabber.org/protocol/muc#admin">>) -> xep0045; get_mod(<<"withtext">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"username">>, <<"jabber:iq:auth">>) -> xep0078; get_mod(<<"required">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>) -> rfc6120; get_mod(<<"phone">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"reported">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"create">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"subject">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"date">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"transport">>, <<"urn:xmpp:jingle:transports:ibb:1">>) -> xep0261; get_mod(<<"auth">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"challenge">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"POBOX">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"invalid-payload">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"leave">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"last">>, <<"jabber:iq:search">>) -> xep0055; get_mod(<<"query">>, <<"jabber:iq:last">>) -> xep0012; get_mod(<<"show">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"configure">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"reason">>, <<"http://jabber.org/protocol/muc#owner">>) -> xep0045; get_mod(<<"candidate-error">>, <<"urn:xmpp:jingle:transports:s5b:1">>) -> xep0260; get_mod(<<"password">>, <<"storage:bookmarks">>) -> xep0048; get_mod(<<"message">>, <<"jabber:component:accept">>) -> rfc6120; get_mod(<<"jid">>, <<"urn:ietf:params:xml:ns:xmpp-bind">>) -> rfc6120; get_mod(<<"PARCEL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"PREF">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"reason">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"never">>, <<"urn:xmpp:mam:2">>) -> xep0313; get_mod(<<"proxy-error">>, <<"urn:xmpp:jingle:transports:s5b:1">>) -> xep0260; get_mod(<<"stat">>, <<"http://jabber.org/protocol/stats">>) -> xep0039; get_mod(<<"always">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"desc">>, <<"jabber:x:oob">>) -> xep0066; get_mod(<<"reason">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"x509-request">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"thread">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"host-unknown">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"unsupported-stanza-type">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"INTERNET">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"title">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"no-copy">>, <<"urn:xmpp:hints">>) -> xep0334; get_mod(<<"subscription">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"addresses">>, <<"http://jabber.org/protocol/address">>) -> xep0033; get_mod(<<"origin-id">>, <<"urn:xmpp:sid:0">>) -> xep0359; get_mod(<<"note">>, <<"http://jabber.org/protocol/commands">>) -> xep0050; get_mod(<<"message">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"MIDDLE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"activate">>, <<"http://jabber.org/protocol/bytestreams">>) -> xep0065; get_mod(<<"password">>, <<"http://jabber.org/protocol/muc">>) -> xep0045; get_mod(<<"r">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"uri">>, <<"urn:xmpp:media-element">>) -> xep0221; get_mod(<<"connection-timeout">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"CRED">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"KEY">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"nick">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"LABEL">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"purge">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"jid">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"prefs">>, <<"urn:xmpp:mam:0">>) -> xep0313; get_mod(<<"forwarded">>, <<"urn:xmpp:forward:0">>) -> xep0297; get_mod(<<"delegation">>, <<"urn:xmpp:delegation:1">>) -> xep0355; get_mod(<<"expired">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"bad-request">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"N">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"PHOTO">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"ORG">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"option">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"sent">>, <<"urn:xmpp:carbons:2">>) -> xep0280; get_mod(<<"db:result">>, <<"jabber:server">>) -> xep0220; get_mod(<<"busy">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"text">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"group">>, <<"jabber:iq:roster">>) -> rfc6121; get_mod(<<"incorrect-encoding">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"before">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"set">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"status">>, <<"jabber:client">>) -> rfc6120; get_mod(<<"item">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"resumed">>, <<"urn:xmpp:sm:3">>) -> xep0198; get_mod(<<"jid">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"activated">>, <<"urn:xmpp:jingle:transports:s5b:1">>) -> xep0260; get_mod(<<"conference">>, <<"storage:bookmarks">>) -> xep0048; get_mod(<<"registered">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"session">>, <<"urn:ietf:params:xml:ns:xmpp-session">>) -> rfc3921; get_mod(<<"closed-node">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"command">>, <<"http://jabber.org/protocol/commands">>) -> xep0050; get_mod(<<"x509-ca-list">>, <<"urn:xmpp:x509:0">>) -> xep0417; get_mod(<<"body">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"restricted-xml">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"HOME">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"end">>, <<"urn:xmpp:mam:tmp">>) -> xep0313; get_mod(<<"retry">>, <<"urn:xmpp:http:upload:0">>) -> xep0363; get_mod(<<"iq">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"list">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"CATEGORIES">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"delete">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"nick">>, <<"jabber:iq:search">>) -> xep0055; get_mod(<<"port">>, <<"urn:xmpp:sic:1">>) -> xep0279; get_mod(<<"desc">>, <<"jabber:x:data">>) -> xep0004; get_mod(<<"no-permanent-store">>, <<"urn:xmpp:hints">>) -> xep0334; get_mod(<<"filename">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"file-too-large">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"storage">>, <<"storage:bookmarks">>) -> xep0048; get_mod(<<"LINE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"PRODID">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"publish-options">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"reason">>, <<"http://jabber.org/protocol/muc#admin">>) -> xep0045; get_mod(<<"policy-violation">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"mechanism">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"default">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"alternative-session">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"remote-server-timeout">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"invalid-from">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"items">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"bad-format">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"STREET">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"status">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"setnick">>, <<"urn:xmpp:mix:core:0">>) -> xep0369; get_mod(<<"error">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"VIDEO">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"redirect">>, <<"http://jabber.org/protocol/pubsub#event">>) -> xep0060; get_mod(<<"destroy">>, <<"http://jabber.org/protocol/muc#user">>) -> xep0045; get_mod(<<"id">>, <<"jabber:x:event">>) -> xep0022; get_mod(<<"not-acceptable">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"SUFFIX">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"redirect">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"incompatible-parameters">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"candidate">>, <<"urn:xmpp:jingle:transports:s5b:1">>) -> xep0260; get_mod(<<"subject">>, <<"jabber:server">>) -> rfc6120; get_mod(<<"bad-namespace-prefix">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"EXTADD">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"affiliation">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"fin">>, <<"urn:xmpp:mam:0">>) -> xep0313; get_mod(<<"enabled">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"TITLE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"too-many-subscriptions">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"item">>, <<"http://jabber.org/protocol/muc#owner">>) -> xep0045; get_mod(<<"always">>, <<"urn:xmpp:mam:0">>) -> xep0313; get_mod(<<"file-too-large">>, <<"urn:xmpp:http:upload:0">>) -> xep0363; get_mod(<<"jingle">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(<<"conflict">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"X400">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"affiliation">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"data">>, <<"urn:xmpp:avatar:data">>) -> xep0084; get_mod(<<"item">>, <<"http://jabber.org/protocol/disco#items">>) -> xep0030; get_mod(<<"VOICE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"vCard">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"gone">>, <<"http://jabber.org/protocol/chatstates">>) -> xep0085; get_mod(<<"query">>, <<"http://jabber.org/protocol/muc#owner">>) -> xep0045; get_mod(<<"os">>, <<"jabber:iq:version">>) -> xep0092; get_mod(<<"feature">>, <<"http://jabber.org/protocol/disco#info">>) -> xep0030; get_mod(<<"ORGNAME">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"NOTE">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"REV">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"query">>, <<"urn:xmpp:mam:1">>) -> xep0313; get_mod(<<"remote-server-not-found">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"invalid-mechanism">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"starttls">>, <<"urn:ietf:params:xml:ns:xmpp-tls">>) -> rfc6120; get_mod(<<"unsupported-feature">>, <<"urn:ietf:params:xml:ns:xmpp-streams">>) -> rfc6120; get_mod(<<"request">>, <<"urn:xmpp:receipts">>) -> xep0184; get_mod(<<"url">>, <<"storage:bookmarks">>) -> xep0048; get_mod(<<"unexpected-request">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"zip">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"delete">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"a">>, <<"urn:xmpp:sm:2">>) -> xep0198; get_mod(<<"dialback">>, <<"urn:xmpp:features:dialback">>) -> xep0220; get_mod(<<"put">>, <<"urn:xmpp:http:upload">>) -> xep0363; get_mod(<<"query">>, <<"jabber:iq:privacy">>) -> xep0016; get_mod(<<"forbidden">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"auth">>, <<"http://jabber.org/features/iq-auth">>) -> xep0078; get_mod(<<"malformed-request">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"username">>, <<"jabber:iq:register">>) -> xep0077; get_mod(<<"paused">>, <<"http://jabber.org/protocol/chatstates">>) -> xep0085; get_mod(<<"version">>, <<"jabber:iq:version">>) -> xep0092; get_mod(<<"publish">>, <<"http://jabber.org/protocol/pubsub">>) -> xep0060; get_mod(<<"count">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"ip">>, <<"urn:xmpp:sic:0">>) -> xep0279; get_mod(<<"text">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>) -> rfc6120; get_mod(<<"temporary-auth-failure">>, <<"urn:ietf:params:xml:ns:xmpp-sasl">>) -> rfc6120; get_mod(<<"ping">>, <<"urn:xmpp:ping">>) -> xep0199; get_mod(<<"CTRY">>, <<"vcard-temp">>) -> xep0054; get_mod(<<"pubsub">>, <<"http://jabber.org/protocol/pubsub#owner">>) -> xep0060; get_mod(<<"item-required">>, <<"http://jabber.org/protocol/pubsub#errors">>) -> xep0060; get_mod(<<"max">>, <<"http://jabber.org/protocol/rsm">>) -> xep0059; get_mod(<<"result">>, <<"urn:xmpp:mam:1">>) -> xep0313; get_mod(<<"max-file-size">>, <<"urn:xmpp:http:upload:0">>) -> xep0363; get_mod(<<"cancel">>, <<"urn:xmpp:jingle:1">>) -> xep0166; get_mod(Name, XMLNS) -> xmpp_codec_external:lookup(Name, XMLNS). get_mod({rosterver_feature}) -> rfc6121; get_mod({legacy_auth_feature}) -> xep0078; get_mod({carbons_disable}) -> xep0280; get_mod({last, _, _}) -> xep0012; get_mod({compression, _}) -> xep0138; get_mod({mam_prefs, _, _, _, _}) -> xep0313; get_mod({upload_file_too_large, _, _}) -> xep0363; get_mod({jingle_ft_description, _}) -> xep0234; get_mod({x509_revoke, _, _}) -> xep0417; get_mod({muc_user, _, _, _, _, _, _}) -> xep0045; get_mod({jidprep, _}) -> xep0328; get_mod({bytestreams, _, _, _, _, _, _}) -> xep0065; get_mod({sasl_auth, _, _}) -> rfc6120; get_mod({vcard_logo, _, _, _}) -> xep0054; get_mod({ps_item, _, _, _, _, _}) -> xep0060; get_mod({mam_fin, _, _, _, _, _}) -> xep0313; get_mod({jingle_ft_error, _}) -> xep0234; get_mod({legacy_auth, _, _, _, _}) -> xep0078; get_mod({stream_features, _}) -> rfc6120; get_mod({muc_item, _, _, _, _, _, _, _}) -> xep0045; get_mod({block_list, _}) -> xep0191; get_mod({carbons_received, _}) -> xep0280; get_mod({carbons_sent, _}) -> xep0280; get_mod({origin_id, _}) -> xep0359; get_mod({hash_used, _}) -> xep0300; get_mod({x509_ca_list, _}) -> xep0417; get_mod({disco_items, _, _, _}) -> xep0030; get_mod({vcard_xupdate, _}) -> xep0153; get_mod({block_item, _, _}) -> xep0191; get_mod({message, _, _, _, _, _, _, _, _, _, _}) -> rfc6120; get_mod({presence, _, _, _, _, _, _, _, _, _, _}) -> rfc6120; get_mod({streamhost, _, _, _}) -> xep0065; get_mod({iq, _, _, _, _, _, _, _}) -> rfc6120; get_mod({vcard_adr, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> xep0054; get_mod({xdata_option, _, _}) -> xep0004; get_mod({ps_unsubscribe, _, _, _}) -> xep0060; get_mod({sm_resume, _, _, _}) -> xep0198; get_mod({push_enable, _, _, _}) -> xep0357; get_mod({jingle_ft_range, _, _, _}) -> xep0234; get_mod({x509_cert_chain, _, _}) -> xep0417; get_mod({vcard_geo, _, _}) -> xep0054; get_mod({mam_query, _, _, _, _, _, _, _, _}) -> xep0313; get_mod({xevent, _, _, _, _, _}) -> xep0022; get_mod({db_result, _, _, _, _, _}) -> xep0220; get_mod({jingle_content, _, _, _, _, _}) -> xep0166; get_mod({bookmark_conference, _, _, _, _, _}) -> xep0048; get_mod({feature_register}) -> xep0077; get_mod({vcard_name, _, _, _, _, _}) -> xep0054; get_mod({pubsub, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> xep0060; get_mod({x_conference, _, _, _, _, _}) -> xep0249; get_mod({csi, _}) -> xep0352; get_mod({mix_join, _, _, _, _}) -> xep0369; get_mod({mix_destroy, _}) -> xep0369; get_mod({disco_info, _, _, _, _}) -> xep0030; get_mod({sm_a, _, _}) -> xep0198; get_mod({mix, _, _, _}) -> xep0369; get_mod({oob_x, _, _, _}) -> xep0066; get_mod({jingle_s5b_transport, _, _, _, _, _, _, _}) -> xep0260; get_mod({privacy_query, _, _, _}) -> xep0016; get_mod({block, _}) -> xep0191; get_mod({vcard_label, _, _, _, _, _, _, _, _}) -> xep0054; get_mod({ps_subscription, _, _, _, _, _, _}) -> xep0060; get_mod({ps_error, _, _}) -> xep0060; get_mod({delay, _, _, _}) -> xep0203; get_mod({muc_actor, _, _}) -> xep0045; get_mod({mix_setnick, _}) -> xep0369; get_mod({nick, _}) -> xep0172; get_mod({jingle, _, _, _, _, _, _, _}) -> xep0166; get_mod({x509_csr, _, _}) -> xep0417; get_mod({x509_challenge_failed}) -> xep0417; get_mod({stats, _, _}) -> xep0039; get_mod({vcard_temp, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> xep0054; get_mod({muc, _, _}) -> xep0045; get_mod({carbons_enable}) -> xep0280; get_mod({carbons_private}) -> xep0280; get_mod({mix_leave}) -> xep0369; get_mod({avatar_info, _, _, _, _, _, _}) -> xep0084; get_mod({privacy_list, _, _}) -> xep0016; get_mod({report, _, _}) -> xep0377; get_mod({message_thread, _, _}) -> rfc6120; get_mod({shim, _}) -> xep0131; get_mod({mam_archived, _, _}) -> xep0313; get_mod({forwarded, _, _}) -> xep0297; get_mod({feature_sm, _}) -> xep0198; get_mod({mix_participant, _, _}) -> xep0369; get_mod({stanza_id, _, _}) -> xep0359; get_mod({delegated, _, _}) -> xep0355; get_mod({text, _, _}) -> xep0234; get_mod({jingle_ft_received, _, _}) -> xep0234; get_mod({bookmark_storage, _, _}) -> xep0048; get_mod({sasl_failure, _, _}) -> rfc6120; get_mod({xmpp_session, _}) -> rfc3921; get_mod({ping}) -> xep0199; get_mod({time, _, _}) -> xep0202; get_mod({ps_subscribe, _, _}) -> xep0060; get_mod({mix_client_leave, _, _}) -> xep0405; get_mod({adhoc_actions, _, _, _, _}) -> xep0050; get_mod({adhoc_note, _, _}) -> xep0050; get_mod({push_disable, _, _}) -> xep0357; get_mod({push_notification, _}) -> xep0357; get_mod({disco_item, _, _, _}) -> xep0030; get_mod({stat, _, _, _, _}) -> xep0039; get_mod({register, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> xep0077; get_mod({pubsub_owner, _, _, _, _, _, _}) -> xep0060; get_mod({mam_result, _, _, _, _}) -> xep0313; get_mod({sm_failed, _, _, _, _}) -> xep0198; get_mod({upload_request, _, _, _, _}) -> xep0363; get_mod({jingle_ft_checksum, _, _, _}) -> xep0234; get_mod({x509_request, _, _, _, _}) -> xep0417; get_mod({version, _, _, _}) -> xep0092; get_mod({vcard_org, _, _}) -> xep0054; get_mod({ps_items, _, _, _, _, _, _}) -> xep0060; get_mod({muc_subscription, _, _, _}) -> p1_mucsub; get_mod({muc_subscribe, _, _, _, _}) -> p1_mucsub; get_mod({feature_csi}) -> xep0352; get_mod({ibb_open, _, _, _}) -> xep0047; get_mod({roster_item, _, _, _, _, _}) -> rfc6121; get_mod({vcard_tel, _, _, _, _, _, _, _, _, _, _, _, _, _, _}) -> xep0054; get_mod({vcard_photo, _, _, _}) -> xep0054; get_mod({ps_publish, _, _}) -> xep0060; get_mod({search_item, _, _, _, _, _}) -> xep0055; get_mod({xcaptcha, _}) -> xep0158; get_mod({avatar_data, _}) -> xep0084; get_mod({hash, _, _}) -> xep0300; get_mod({roster_query, _, _}) -> rfc6121; get_mod({vcard_key, _, _}) -> xep0054; get_mod({sm_r, _}) -> xep0198; get_mod({media_uri, _, _}) -> xep0221; get_mod({upload_slot_0, _, _, _}) -> xep0363; get_mod({delegation_query, _, _}) -> xep0355; get_mod({jingle_error, _}) -> xep0166; get_mod({jingle_s5b_candidate, _, _, _, _, _, _}) -> xep0260; get_mod({sasl_success, _}) -> rfc6120; get_mod({compress, _}) -> xep0138; get_mod({xdata_field, _, _, _, _, _, _, _, _}) -> xep0004; get_mod({muc_subscriptions, _}) -> p1_mucsub; get_mod({addresses, _}) -> xep0033; get_mod({adhoc_command, _, _, _, _, _, _, _, _}) -> xep0050; get_mod({media, _, _, _}) -> xep0221; get_mod({ibb_data, _, _, _}) -> xep0047; get_mod({identity, _, _, _, _}) -> xep0030; get_mod({redirect, _}) -> rfc6120; get_mod({muc_history, _, _, _, _}) -> xep0045; get_mod({muc_owner, _, _, _}) -> xep0045; get_mod({jingle_ft_file, _, _, _, _, _, _, _, _}) -> xep0234; get_mod({bookmark_url, _, _}) -> xep0048; get_mod({gone, _}) -> rfc6120; get_mod({sasl_response, _}) -> rfc6120; get_mod({chatstate, _}) -> xep0085; get_mod({muc_unique, _}) -> xep0045; get_mod({mix_create, _}) -> xep0369; get_mod({receipt_response, _}) -> xep0184; get_mod({sic, _, _, _}) -> xep0279; get_mod({idle, _}) -> xep0319; get_mod({sm_resumed, _, _, _}) -> xep0198; get_mod({offline_item, _, _}) -> xep0013; get_mod({db_verify, _, _, _, _, _, _}) -> xep0220; get_mod({upload_slot, _, _, _}) -> xep0363; get_mod({jingle_ibb_transport, _, _, _}) -> xep0261; get_mod({muc_decline, _, _, _}) -> xep0045; get_mod({sm_enable, _, _, _}) -> xep0198; get_mod({offline, _, _, _}) -> xep0013; get_mod({mix_client_join, _, _}) -> xep0405; get_mod({address, _, _, _, _, _}) -> xep0033; get_mod({thumbnail, _, _, _, _}) -> xep0264; get_mod({delegation, _, _}) -> xep0355; get_mod({x509_challenge, _, _, _}) -> xep0417; get_mod({sm_enabled, _, _, _, _, _}) -> xep0198; get_mod({vcard_email, _, _, _, _, _, _}) -> xep0054; get_mod({ps_affiliation, _, _, _, _}) -> xep0060; get_mod({upload_retry, _}) -> xep0363; get_mod({x509_register}) -> xep0417; get_mod({rsm_set, _, _, _, _, _, _, _}) -> xep0059; get_mod({avatar_meta, _, _}) -> xep0084; get_mod({unblock, _}) -> xep0191; get_mod({stat_error, _, _}) -> xep0039; get_mod({sasl_abort}) -> rfc6120; get_mod({starttls_proceed}) -> rfc6120; get_mod({compressed}) -> xep0138; get_mod({stream_error, _, _}) -> rfc6120; get_mod({receipt_request}) -> xep0184; get_mod({upload_request_0, _, _, _, _}) -> xep0363; get_mod({privacy_item, _, _, _, _, _, _, _, _}) -> xep0016; get_mod({starttls_failure}) -> rfc6120; get_mod({bob_data, _, _, _, _}) -> xep0231; get_mod({bind, _, _}) -> rfc6120; get_mod({rsm_first, _, _}) -> xep0059; get_mod({caps, _, _, _, _}) -> xep0115; get_mod({xdata, _, _, _, _, _, _}) -> xep0004; get_mod({ps_options, _, _, _, _}) -> xep0060; get_mod({muc_admin, _}) -> xep0045; get_mod({muc_unsubscribe, _, _}) -> p1_mucsub; get_mod({search, _, _, _, _, _, _, _}) -> xep0055; get_mod({expire, _, _}) -> xep0023; get_mod({privilege, _, _}) -> xep0356; get_mod({stanza_error, _, _, _, _, _, _}) -> rfc6120; get_mod({avatar_pointer, _, _, _, _, _, _}) -> xep0084; get_mod({muc_invite, _, _, _, _}) -> xep0045; get_mod({jingle_reason, _, _, _}) -> xep0166; get_mod({ps_event, _, _, _, _, _, _}) -> xep0060; get_mod({sasl_mechanisms, _}) -> rfc6120; get_mod({starttls, _}) -> rfc6120; get_mod({stream_start, _, _, _, _, _, _, _, _}) -> rfc6120; get_mod({'see-other-host', _}) -> rfc6120; get_mod({muc_destroy, _, _, _, _}) -> xep0045; get_mod({hint, _}) -> xep0334; get_mod({private, _}) -> xep0049; get_mod({sasl_challenge, _}) -> rfc6120; get_mod({compress_failure, _}) -> xep0138; get_mod({db_feature, _}) -> xep0220; get_mod({handshake, _}) -> xep0114; get_mod({ibb_close, _}) -> xep0047; get_mod({vcard_sound, _, _, _}) -> xep0054; get_mod({ps_retract, _, _, _}) -> xep0060; get_mod({privilege_perm, _, _}) -> xep0356; get_mod(Record) -> xmpp_codec_external:lookup(Record). xmpp-1.4.4/src/xdata_codec.erl0000644000232200023220000006374713610066730016626 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% %%% @end %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xdata_codec). %% API -export([compile/1, compile/2]). -export([dec_int/1, dec_int/3, dec_enum/2, dec_bool/1, not_empty/1, dec_enum_int/2, dec_enum_int/4, enc_int/1, enc_enum/1, enc_bool/1, enc_enum_int/1, dec_ip/1, enc_ip/1, format_error/1, io_format_error/1]). -include("xmpp.hrl"). -type mfargs() :: {atom(), atom(), list()} | {atom(), list()}. -record(state, {mod_name :: atom(), file_name :: string(), erl = "" :: string(), hrl = "" :: string(), dir = "" :: string(), xmlns = [] :: [string()], doc = <<>> :: binary(), erl_dir = "" :: string(), hrl_dir = "" :: string(), prefix = [] :: [binary()], dec_mfas = [] :: [{binary(), mfargs()}], enc_mfas = [] :: [{binary(), mfargs()}], specs = [] :: [{binary(), string()}], ignore_unknown = false :: boolean(), required = [] :: [{binary(), boolean()} | binary()], defaults = [] :: [{binary(), any()}]}). -define(is_multi_type(T), ((T == 'list-multi') or (T == 'jid-multi') or (T == 'text-multi'))). -define(is_list_type(T), ((T == 'list-single') or (T == 'list-multi'))). %%%=================================================================== %%% API %%%=================================================================== compile(Path) -> compile(Path, []). compile(Path, Opts) -> case filelib:is_dir(Path) of true -> filelib:fold_files( Path, ".*.xdata", false, fun(File, ok) -> compile_file(File, Opts); (_, Err) -> Err end, ok); false -> compile_file(Path, Opts) end. compile_file(Path, Opts) -> try {ok, _} = application:ensure_all_started(fast_xml), DirName = filename:dirname(Path), FileName = filename:basename(Path), RootName = filename:rootname(FileName), ConfigPath = filename:join(DirName, RootName) ++ ".cfg", ModName = list_to_atom(RootName), {ok, Data} = file:read_file(Path), Config = case file:consult(ConfigPath) of {ok, Terms} -> lists:flatten(Terms); {error, enoent} -> [] end, State = #state{mod_name = ModName, file_name = FileName, erl = filename:rootname(FileName) ++ ".erl", hrl = filename:rootname(FileName) ++ ".hrl", dir = DirName, prefix = proplists:get_all_values(prefix, Config), erl_dir = proplists:get_value(erl_dir, Opts, DirName), hrl_dir = proplists:get_value(hrl_dir, Opts, DirName), dec_mfas = proplists:get_value(decode, Config, []), enc_mfas = proplists:get_value(encode, Config, []), specs = proplists:get_value(specs, Config, []), ignore_unknown = proplists:get_bool(ignore_unknown, Config), required = proplists:get_value(required, Config, []), defaults = proplists:get_value(defaults, Config, [])}, #xmlel{} = El = fxml_stream:parse_element(Data), ok = compile_element(normalize(El), State), io:format("Compiled ~s~n", [Path]) catch _:{badmatch, Err} -> io:format(standard_error, "Failed to compile ~s: ~p~n", [Path, Err]), Err end. emit_raw(Str) -> put(outbuf, get(outbuf) ++ Str). emit(Format) -> emit(Format, []). emit(Format, Args) -> put(outbuf, get(outbuf) ++ io_lib:format(Format, Args)). dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val, Min, Max) -> case erlang:binary_to_integer(Val) of Int when Int =< Max, Min == infinity -> Int; Int when Int =< Max, Int >= Min -> Int end. enc_int(Int) -> integer_to_binary(Int). dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). dec_enum_int(Val, Enums) -> try dec_int(Val) catch _:_ -> dec_enum(Val, Enums) end. dec_enum_int(Val, Enums, Min, Max) -> try dec_int(Val, Min, Max) catch _:_ -> dec_enum(Val, Enums) end. enc_enum_int(Int) when is_integer(Int) -> enc_int(Int); enc_enum_int(Atom) -> enc_enum(Atom). dec_bool(<<"1">>) -> true; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"false">>) -> false. enc_bool(true) -> <<"1">>; enc_bool(false) -> <<"0">>. not_empty(<<_, _/binary>> = Val) -> Val. dec_ip(Val) -> {ok, Addr} = inet_parse:address(binary_to_list(Val)), Addr. enc_ip({0,0,0,0,0,16#ffff,A,B}) -> enc_ip({(A bsr 8) band 16#ff, A band 16#ff, (B bsr 8) band 16#ff, B band 16#ff}); enc_ip(Addr) -> list_to_binary(inet_parse:ntoa(Addr)). format_error({form_type_mismatch, Type}) -> <<"FORM_TYPE doesn't match '", Type/binary, "'">>; format_error({bad_var_value, Var, Type}) -> <<"Bad value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_value, Var, Type}) -> <<"Missing value of field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({too_many_values, Var, Type}) -> <<"Too many values for field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({unknown_var, Var, Type}) -> <<"Unknown field '", Var/binary, "' of type '", Type/binary, "'">>; format_error({missing_required_var, Var, Type}) -> <<"Missing required field '", Var/binary, "' of type '", Type/binary, "'">>. io_format_error({form_type_mismatch, Type}) -> {<<"FORM_TYPE doesn't match '~s'">>, [Type]}; io_format_error({bad_var_value, Var, Type}) -> {<<"Bad value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_value, Var, Type}) -> {<<"Missing value of field '~s' of type '~s'">>, [Var, Type]}; io_format_error({too_many_values, Var, Type}) -> {<<"Too many values for field '~s' of type '~s'">>, [Var, Type]}; io_format_error({unknown_var, Var, Type}) -> {<<"Unknown field '~s' of type '~s'">>, [Var, Type]}; io_format_error({missing_required_var, Var, Type}) -> {<<"Missing required field '~s' of type '~s'">>, [Var, Type]}. %%%=================================================================== %%% Internal functions %%%=================================================================== compile_element(#xmlel{name = <<"form_type">>, children = Els} = Form, #state{erl = OutErl, erl_dir = ErlDir, hrl = OutHrl, hrl_dir = HrlDir} = State0) -> try Names = lists:flatmap( fun(#xmlel{name = <<"name">>} = Tag) -> case fxml:get_tag_cdata(Tag) of <<"">> -> []; N -> [binary_to_list(N)] end; (_) -> [] end, Els), Doc = fxml:get_subtag_cdata(Form, <<"doc">>), X = #xmlel{name = <<"x">>, attrs = [{<<"type">>, <<"form">>}, {<<"xmlns">>, <<"jabber:x:data">>}], children = Els}, State = State0#state{xmlns = Names, doc = Doc}, #xdata{fields = Fs} = xmpp_codec:decode(X), put(outbuf, []), mk_header(State), mk_specs(Fs, State), mk_aux_funs(), mk_top_decoder(Fs, State), mk_top_encoder(Fs, State), mk_decoder(Fs, State), mk_encoders(Fs, State), ErlData = get(outbuf), ok = file:write_file(filename:join(ErlDir, OutErl), ErlData), ok = erl_tidy:file(filename:join(ErlDir, OutErl), [{backups, false}, {keep_unused, true}]), put(outbuf, []), mk_type_definitions(Fs, State), HrlData = get(outbuf), ok = file:write_file(filename:join(HrlDir, OutHrl), HrlData) catch _:{badmatch, Err} -> Err end. mk_aux_funs() -> case get_abstract_code_from_myself() of {ok, AbsCode} -> AST = lists:filter( fun(T) -> try erl_syntax_lib:analyze_function(T) of {format_error, 1} -> true; {io_format_error, 1} -> true; FA -> lists:member(FA, codec_funs()) catch _:_ -> false end end, AbsCode), emit_raw(erl_prettypr:format(erl_syntax:form_list(AST)) ++ io_lib:nl()); error -> erlang:error({no_abstract_code_found, ?MODULE}) end. get_abstract_code_from_myself() -> {file, File} = code:is_loaded(?MODULE), case beam_lib:chunks(File, [abstract_code]) of {ok, {_, List}} -> case lists:keyfind(abstract_code, 1, List) of {abstract_code, {raw_abstract_v1, Abstr}} -> {ok, Abstr}; _ -> error end; _ -> error end. mk_comment_header(#state{file_name = Source, xmlns = NS, doc = Doc}) -> emit("%% Created automatically by xdata generator (xdata_codec.erl)~n" "%% Source: ~s~n" "%% Form type: ~s~n", [Source, string:join(NS, ", ")]), if Doc /= <<>> -> emit("%% Document: ~s~n~n", [Doc]); true -> emit("~n") end. mk_header(#state{mod_name = Mod, hrl = Include, xmlns = NS} = State) -> mk_comment_header(State), emit("~n-module(~s).~n", [Mod]), emit("-compile({nowarn_unused_function, ~p}).~n", [codec_funs()]), emit("-compile(nowarn_unused_vars).~n"), emit("-dialyzer({nowarn_function, dec_int/3}).~n"), case NS of [_] -> emit("-export([encode/1, encode/2, encode/3]).~n"); _ -> emit("-export([encode/2, encode/3, encode/4]).~n") end, emit("-export([decode/1, decode/2, decode/3, format_error/1, io_format_error/1]).~n"), emit("-include(\"xmpp_codec.hrl\").~n"), emit("-include(\"~s\").~n", [Include]), emit("-export_type([property/0, result/0, form/0, error_reason/0]).~n"), emit("-define(T(S), <>).~n"). mk_specs(Fs, State) -> emit("-spec format_error(error_reason()) -> binary().~n"), emit("-spec io_format_error(error_reason()) -> {binary(), [binary()]}.~n"), emit("-spec decode([xdata_field()]) -> result().~n"), emit("-spec decode([xdata_field()], [binary(), ...]) -> result().~n"), emit("-spec decode([xdata_field()], [binary(), ...], [binary()]) -> result().~n"), emit("-spec decode([xdata_field()], [binary(), ...], [binary()], result()) -> result().~n"), emit("-spec do_decode([xdata_field()], binary(), [binary()], result()) -> result().~n"), BinType = case State#state.xmlns of [_] -> ""; _ -> ", binary()" end, Required = [io_lib:format("'~s'", [var_to_rec_field(Var, State)]) || #xdata_field{var = Var} <- Fs], emit("-spec encode(form()~s) -> [xdata_field()].~n", [BinType]), emit("-spec encode(form()~s, binary()) -> [xdata_field()].~n", [BinType]), emit("-spec encode(form()~s, binary(), [~s]) -> [xdata_field()].~n", [BinType, string:join(Required, " | ")]). mk_type_definitions(Fs, State) -> mk_comment_header(State), lists:foreach( fun(#xdata_field{var = Var} = F) -> Spec = get_typespec(F, State), case is_complex_type(Spec) of true -> emit("-type '~s'() :: ~s.~n", [var_to_rec_field(Var, State), Spec]); false -> ok end end, Fs), emit("~n-type property() :: "), Fields = lists:map( fun(#xdata_field{var = Var} = F) -> RecField = var_to_rec_field(Var, State), [io_lib:format("{'~s', ~s}", [RecField, mk_typespec(F, State)])] end, Fs), emit(string:join(Fields, " |~n ") ++ ".~n"), emit("-type result() :: [property()].~n~n"), Options = lists:flatmap( fun(#xdata_field{type = T, var = Var} = F) -> RecName = var_to_rec_field(Var, State), Spec1 = mk_typespec(F, State), Spec2 = case default(F, State) of undefined -> Spec1 ++ " | undefined"; _ -> Spec1 end, [io_lib:format("{'~s', ~s}", [RecName, Spec2])| if ?is_list_type(T) -> Spec3 = get_typespec(F, State), Spec4 = case is_complex_type(Spec3) of true -> io_lib:format("'~s'()", [RecName]); false -> Spec3 end, [io_lib:format( "{'~s', ~s, options(~s)}", [RecName, Spec2, Spec4])]; true -> [] end] end, Fs), case lists:any(fun(#xdata_field{type = T}) -> ?is_list_type(T) end, Fs) of true -> emit("-type options(T) :: [{binary(), T}].~n"); false -> ok end, emit("-type form_property() ::~n "), emit(string:join(Options, " |~n ") ++ ".~n"), emit("-type form() :: [form_property() | xdata_field()].~n~n"), emit("-type error_reason() :: {form_type_mismatch, binary()} |~n" " {bad_var_value, binary(), binary()} |~n" " {missing_required_var, binary(), binary()} |~n" " {missing_value, binary(), binary()} |~n" " {too_many_values, binary(), binary()} |~n" " {unknown_var, binary(), binary()}.~n"). mk_top_decoder(Fs, State) -> Required = [Var || #xdata_field{var = Var} <- Fs, is_required(Var, State)], NSList = "[" ++ string:join(["<<\"" ++ NS ++ "\">>" || NS <- State#state.xmlns], ", ") ++ "]", emit("decode(Fs) -> decode(Fs, ~s, ~p, []).~n", [NSList, Required]), emit("decode(Fs, XMLNSList) -> decode(Fs, XMLNSList, ~p, []).~n", [Required]), emit("decode(Fs, XMLNSList, Required) -> decode(Fs, XMLNSList, Required, []).~n"), emit("decode(Fs, [_|_] = XMLNSList, Required, Acc) ->" " case lists:keyfind(<<\"FORM_TYPE\">>, #xdata_field.var, Fs) of" " false ->" " do_decode(Fs, hd(XMLNSList), Required, Acc);" " #xdata_field{values = [XMLNS]} ->" " case lists:member(XMLNS, XMLNSList) of" " true -> do_decode(Fs, XMLNS, Required, Acc);" " false -> erlang:error({?MODULE, {form_type_mismatch, XMLNS}})" " end" " end.~n"). mk_top_encoder(Fs, State) -> Required = "[" ++ string:join( [io_lib:format("'~s'", [var_to_rec_field(Var, State)]) || #xdata_field{var = Var} <- Fs, is_required(Var, State)], ", ") ++ "]", Clauses = string:join( lists:map( fun(#xdata_field{var = Var, type = T}) when ?is_list_type(T) -> Field = var_to_rec_field(Var, State), io_lib:format( "{'~s', Val} ->" " ['encode_~s'(Val, default, Lang, lists:member('~s', Required))];" "{'~s', Val, Opts} ->" " ['encode_~s'(Val, Opts, Lang, lists:member('~s', Required))]", [Field, Field, Field, Field, Field, Field]); (#xdata_field{var = Var}) -> Field = var_to_rec_field(Var, State), io_lib:format( "{'~s', Val} -> ['encode_~s'(Val, Lang, lists:member('~s', Required))]", [Field, Field, Field]) end, Fs) ++ ["#xdata_field{} -> [Opt]"], ";"), case State#state.xmlns of [_] -> emit("encode(Cfg) -> encode(Cfg, <<\"en\">>, ~s).~n", [Required]), emit("encode(Cfg, Lang) -> encode(Cfg, Lang, ~s).~n", [Required]), emit("encode(List, Lang, Required) ->"); _ -> emit("encode(Cfg, XMLNS) -> encode(Cfg, XMLNS, <<\"en\">>, ~s).~n", [Required]), emit("encode(Cfg, XMLNS, Lang) -> encode(Cfg, XMLNS, Lang, ~s).~n", [Required]), emit("encode(List, XMLNS, Lang, Required) ->") end, XMLNS = case State#state.xmlns of [NS] -> io_lib:format("<<~p>>", [NS]); _ -> "XMLNS" end, emit(" Fs = [case Opt of ~s end || Opt <- List]," " FormType = #xdata_field{var = <<\"FORM_TYPE\">>, type = hidden," " values = [~s]}," " [FormType|lists:flatten(Fs)].~n", [Clauses, XMLNS]). mk_decoder([#xdata_field{var = Var, type = Type} = F|Fs], State) -> ValVar = if ?is_multi_type(Type) -> "Values"; true -> "[Value]" end, DecFun = if ?is_multi_type(Type) -> ["[", mk_decoding_fun(F, State), " || Value <- Values]"]; true -> mk_decoding_fun(F, State) end, DelRequired = io_lib:format("lists:delete(~p, Required)", [Var]), if Type == 'jid-multi' -> %% Psi work-around emit("do_decode([#xdata_field{var = ~p, values = [<<>>]} = F|Fs]," " XMLNS, Required, Acc) ->~n" " %% Psi work-around~n" " do_decode([F#xdata_field{var = ~p, values = []}|Fs]," " XMLNS, Required, Acc);", [Var, Var]); true -> ok end, emit("do_decode([#xdata_field{var = ~p, values = ~s}|Fs], XMLNS, Required, Acc) ->" " try ~s of" " Result -> do_decode(Fs, XMLNS, ~s, [{'~s', Result}|Acc])" " catch _:_ ->" " erlang:error({?MODULE, {bad_var_value, ~p, XMLNS}})" " end;", [Var, ValVar, DecFun, DelRequired, var_to_rec_field(Var, State), Var]), if not ?is_multi_type(Type) -> emit("do_decode([#xdata_field{var = ~p, values = []} = F|Fs]," " XMLNS, Required, Acc) ->" " do_decode([F#xdata_field{var = ~p, values = [<<>>]}|Fs]," " XMLNS, Required, Acc);", [Var, Var]), emit("do_decode([#xdata_field{var = ~p}|_], XMLNS, _, _) ->" " erlang:error({?MODULE, {too_many_values, ~p, XMLNS}});", [Var, Var]); true -> ok end, mk_decoder(Fs, State); mk_decoder([], State) -> if State#state.ignore_unknown -> emit("do_decode([_|Fs], XMLNS, Required, Acc) ->" " do_decode(Fs, XMLNS, Required, Acc);"); true -> emit("do_decode([#xdata_field{var = Var}|Fs], XMLNS, Required, Acc) ->" " if Var /= <<\"FORM_TYPE\">> ->" " erlang:error({?MODULE, {unknown_var, Var, XMLNS}});" " true ->" " do_decode(Fs, XMLNS, Required, Acc)" " end;") end, emit("do_decode([], XMLNS, [Var|_], _) ->" " erlang:error({?MODULE, {missing_required_var, Var, XMLNS}});~n"), emit("do_decode([], _, [], Acc) -> Acc.~n"). mk_encoders(Fs, State) -> lists:foreach( fun(#xdata_field{var = Var, desc = Desc, label = Label, type = Type} = F) -> Spec0 = mk_typespec(F, State), Spec1 = case default(F, State) of undefined -> Spec0 ++ " | undefined"; _ -> Spec0 end, EncVals = mk_encoded_values(F, State), EncOpts = mk_encoded_options(F, State), FieldName = var_to_rec_field(Var, State), DescStr = if Desc == <<>> -> "<<>>"; true -> io_lib:format("xmpp_tr:tr(Lang, ?T(\"~s\"))", [Desc]) end, LabelStr = if Label == <<>> -> "<<>>"; true -> io_lib:format("xmpp_tr:tr(Lang, ?T(\"~s\"))", [Label]) end, if ?is_list_type(Type) -> Spec2 = get_typespec(F, State), Spec3 = case is_complex_type(Spec2) of true -> io_lib:format("'~s'()", [FieldName]); false -> Spec2 end, emit("-spec 'encode_~s'(~s, default | options(~s), binary(), boolean()) -> xdata_field().~n" "'encode_~s'(Value, Options, Lang, IsRequired) ->", [FieldName, Spec1, Spec3, FieldName]); true -> emit("-spec 'encode_~s'(~s, binary(), boolean()) -> xdata_field().~n" "'encode_~s'(Value, Lang, IsRequired) ->", [FieldName, Spec1, FieldName]) end, emit(" Values = ~s," " Opts = ~s," " #xdata_field{var = ~p," " values = Values," " required = IsRequired," " type = ~p," " options = Opts," " desc = ~s," " label = ~s}.~n", [EncVals, EncOpts, Var, Type, DescStr, LabelStr]) end, Fs). mk_encoded_values(#xdata_field{var = Var, type = Type, options = Options} = F, State) -> EncFun = case get_enc_fun(Var, Type, Options, State) of {M, Fun, Args} -> Mod = if M == undefined -> ""; true -> io_lib:format("~s:", [M]) end, FArgs = [io_lib:format(", ~p", [A]) || A <- Args], if ?is_multi_type(Type) -> "[" ++ io_lib:format("~s~s(V~s)", [Mod, Fun, FArgs]) ++ " || V <- Value]"; true -> "[" ++ io_lib:format("~s~s(Value~s)", [Mod, Fun, FArgs]) ++ "]" end; undefined when ?is_multi_type(Type) -> "Value"; undefined -> "[Value]" end, io_lib:format( "case Value of" " ~p -> [];~n" " Value -> ~s~n" "end", [default(F, State), EncFun]). mk_encoded_options(#xdata_field{var = Var, type = Type, options = Options}, State) -> EncFun = case get_enc_fun(Var, Type, Options, State) of {M, Fun, Args} -> Mod = if M == undefined -> ""; true -> io_lib:format("~s:", [M]) end, FArgs = [io_lib:format(", ~p", [A]) || A <- Args], io_lib:format("~s~s(V~s)", [Mod, Fun, FArgs]); undefined -> "V" end, EncOpts = string:join( [case L of <<>> -> io_lib:format("#xdata_option{value = ~p}", [V]); _ -> io_lib:format( "#xdata_option{label = xmpp_tr:tr(Lang, ?T(\"~s\")), value = ~p}", [L, V]) end || #xdata_option{label = L, value = V} <- Options], ","), if ?is_list_type(Type) -> io_lib:format( "if Options == default ->" " [~s];" "true ->" " [#xdata_option{label = xmpp_tr:tr(Lang, L), value = ~s}" " || {L, V} <- Options]" "end", [EncOpts, EncFun]); true -> "[]" end. mk_decoding_fun(#xdata_field{var = Var, type = Type, options = Options}, State) -> case get_dec_fun(Var, Type, Options, State) of {M, Fun, Args} -> Mod = if M == undefined -> ""; true -> io_lib:format("~s:", [M]) end, FArgs = [io_lib:format(", ~p", [A]) || A <- Args], io_lib:format("~s~s(Value~s)", [Mod, Fun, FArgs]); undefined -> "Value" end. var_to_rec_field(Var, #state{prefix = [Prefix|T]} = State) -> Size = size(Prefix), case Var of <<(Prefix):Size/binary, Rest/binary>> -> binary_to_atom(Rest, utf8); _ -> var_to_rec_field(Var, State#state{prefix = T}) end; var_to_rec_field(Var, #state{prefix = []}) -> Var. get_dec_fun(Var, Type, Options, State) -> case lists:keyfind(Var, 1, State#state.dec_mfas) of false when Type == 'list-multi'; Type == 'list-single' -> if Options /= [] -> Variants = [binary_to_atom(V, utf8) || #xdata_option{value = V} <- Options], {undefined, dec_enum, [Variants]}; true -> undefined end; false when Type == 'jid-multi'; Type == 'jid-single' -> {jid, decode, []}; false when Type == boolean -> {undefined, dec_bool, []}; false -> undefined; {Var, {M, F, A}} -> {M, F, A}; {Var, {dec_bool, []}} -> {undefined, dec_bool, []}; {Var, {dec_ip, []}} -> {undefined, dec_ip, []}; {Var, {not_empty, []}} -> {undefined, not_empty, []}; {Var, {dec_enum, [Variants]}} -> {undefined, dec_enum, [Variants]}; {Var, {dec_int, Args}} -> {undefined, dec_int, Args}; {Var, {dec_enum_int, Args}} -> {undefined, dec_enum_int, Args} end. get_enc_fun(Var, Type, Options, State) -> case get_dec_fun(Var, Type, Options, State) of {undefined, dec_enum, _} -> {undefined, enc_enum, []}; {undefined, dec_bool, _} -> {undefined, enc_bool, []}; {undefined, dec_int, _} -> {undefined, enc_int, []}; {undefined, dec_enum_int, _} -> {undefined, enc_enum_int, []}; {undefined, dec_ip, _} -> {undefined, enc_ip, []}; {jid, decode, []} -> {jid, encode, []}; _ -> case lists:keyfind(Var, 1, State#state.enc_mfas) of false -> undefined; {Var, {jid, decode, []}} -> {jid, encode, []}; {Var, {M, F, A}} -> {M, F, A}; {Var, {enc_bool, []}} -> {undefined, enc_bool, []}; {Var, {dec_enum, _}} -> {undefined, enc_enum, []}; {Var, {enc_int, _}} -> {undefined, enc_int, []}; {Var, {dec_enum_int, _}} -> {undefined, enc_enum_int, []}; {Var, {dec_ip, _}} -> {undefined, enc_ip, []} end end. mk_typespec(#xdata_field{type = Type, var = Var} = Field, State) -> Spec0 = get_typespec(Field, State), Spec1 = case is_complex_type(Spec0) of true -> io_lib:format("'~s'()", [var_to_rec_field(Var, State)]); false -> Spec0 end, if ?is_multi_type(Type) -> "[" ++ Spec1 ++ "]"; true -> Spec1 end. get_typespec(#xdata_field{var = Var, type = Type, options = Options}, State) -> case lists:keyfind(Var, 1, State#state.specs) of false -> case get_dec_fun(Var, Type, Options, State) of {undefined, dec_enum, Args} -> enum_spec(Args); {undefined, dec_bool, _} -> "boolean()"; {undefined, dec_ip, _} -> "inet:ip_address()"; {jid, decode, _} -> "jid:jid()"; {undefined, dec_int, Args} -> int_spec(Args); {undefined, dec_enum_int, [Variants|T]} -> enum_spec([Variants]) ++ " | " ++ int_spec(T); _ -> "binary()" end; {Var, Spec} -> Spec end. -spec is_complex_type(string()) -> boolean(). is_complex_type(Spec) -> string:chr(Spec, $|) /= 0. int_spec([]) -> "integer()"; int_spec([From, To]) -> if From /= infinity, To /= infinity -> io_lib:format("~p..~p", [From, To]); From > 0 -> "pos_integer()"; From == 0 -> "non_neg_integer()"; true -> "integer()" end. enum_spec([Variants]) -> string:join([atom_to_list(V) || V <- Variants], " | "). is_required(Var, State) -> lists:member(Var, State#state.required) orelse proplists:get_bool(Var, State#state.required). normalize(#xmlel{name = Name, attrs = Attrs, children = Els}) -> #xmlel{name = Name, attrs = [normalize(Attr) || Attr <- Attrs], children = [normalize(El) || El <- Els]}; normalize({Key, Data}) -> {Key, normalize(Data)}; normalize(Txt) when is_binary(Txt) -> case re:split(Txt, "[\\s\\r\\n\\t]+", [trim, {return, list}]) of [""|T] -> list_to_binary(string:join(T, " ")); T -> list_to_binary(string:join(T, " ")) end. default(#xdata_field{type = Type}, _) when ?is_multi_type(Type) -> []; default(#xdata_field{var = Var, type = Type, options = Options}, State) -> case get_dec_fun(Var, Type, Options, State) of undefined -> <<>>; _MFA -> undefined end. codec_funs() -> [{dec_int, 3}, {dec_int, 1}, {dec_enum, 2}, {dec_enum_int, 2}, {dec_enum_int, 4}, {enc_int, 1}, {enc_enum, 1}, {enc_enum_int, 1}, {not_empty, 1}, {dec_bool, 1}, {enc_bool, 1}, {dec_ip, 1}, {enc_ip, 1}]. xmpp-1.4.4/src/xmpp.app.src0000644000232200023220000000320213610066730016114 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% %%% @end %%% Created : 18 Nov 2016 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- {application, xmpp, [{description, "Erlang/Elixir XMPP parsing and serialization library"}, {vsn, "1.4.4"}, {modules, []}, {registered, []}, {applications, [kernel, stdlib]}, {mod, {xmpp, []}}, {env, []}, %% hex.pm packaging: {files, ["src/", "specs/", "asn1/", "include/", "c_src/jid.c", "c_src/xmpp_uri.c", "c_src/xmpp_lang.c", "rebar.config", "rebar.config.script", "README.md", "LICENSE.txt"]}, {exclude_files, ["src/XmppAddr.erl", "src/XmppAddr.asn1db", "include/XmppAddr.hrl"]}, {licenses, ["Apache 2.0"]}, {links, [{"Github", "https://github.com/processone/xmpp"}]}]}. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/src/jid.erl0000644000232200023220000001523513610066730015123 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% JID processing library %%% @end %%% Created : 24 Nov 2015 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(jid). %% API -export([start/0, make/1, make/2, make/3, split/1, decode/1, encode/1, is_nodename/1, nodeprep/1, nameprep/1, resourceprep/1, tolower/1, remove_resource/1, replace_resource/2]). %% to_string/1 and from_string/1 are deprecated for the following reasons: %% (1) The naming is misleading, because there are actually no strings to %% decode/encode %% (2) What's more important, a user typically doesn't check the output %% of from_string/1, which leads to hard to debug side effects, %% because the value of 'error' is propagated downstream and will fail %% in unexpected places where it's impossible to understand where %% this 'error' value came from; thus, it's much better to generate %% an exception; to_string/1 is renamed to encode/1 for consistency %% (3) As a consequence of (2) Dialyzer produces typings in the form %% of 'error | #jid{}' for some functions which is not very good -export([from_string/1, to_string/1]). -deprecated([{from_string, 1}, {to_string, 1}]). %% For tests only -export([string_to_usr/1]). -include("jid.hrl"). -export_type([jid/0]). -export_type([ljid/0]). %%%=================================================================== %%% API %%%=================================================================== -spec start() -> ok | {error, unable_to_load_nif}. start() -> load_nif(p1_nif_utils:get_so_path(?MODULE, [jid], "jid")). load_nif(SOPath) -> case catch erlang:load_nif(SOPath, 0) of ok -> ok; {error, {reload, _}} -> ok; Err -> error_logger:warning_msg("unable to load jid NIF: ~p~n", [Err]), {error, unable_to_load_nif} end. -spec make(binary(), binary(), binary()) -> jid() | error. make(User, Server, Resource) -> case nodeprep(User) of error -> error; LUser -> case nameprep(Server) of error -> error; LServer -> case resourceprep(Resource) of error -> error; LResource -> #jid{user = User, server = Server, resource = Resource, luser = LUser, lserver = LServer, lresource = LResource} end end end. -spec make(binary(), binary()) -> jid() | error. make(User, Server) -> make(User, Server, <<"">>). -spec make({binary(), binary(), binary()} | binary()) -> jid() | error. make({User, Server, Resource}) -> make(User, Server, Resource); make(Server) -> make(<<"">>, Server, <<"">>). %% This is the reverse of make_jid/1 -spec split(jid()) -> {binary(), binary(), binary()} | error. split(#jid{user = U, server = S, resource = R}) -> {U, S, R}; split(_) -> error. -spec string_to_usr(binary()) -> {binary(), binary(), binary()} | error. string_to_usr(_S) -> erlang:nif_error(nif_not_loaded). -spec from_string(binary() | string()) -> jid() | error. from_string(S) when is_list(S) -> %% We do not accept list because we want to enforce good practice of %% using binaries for string. However, we do not let it crash to avoid %% losing associated ets table. {error, need_jid_as_binary}; from_string(<<>>) -> error; from_string(S) when is_binary(S) -> make(string_to_usr(S)). -spec decode(binary()) -> jid(). decode(S) when is_binary(S) -> case string_to_usr(S) of error -> erlang:error({bad_jid, S}); Val -> case make(Val) of error -> erlang:error({bad_jid, S}); Prepped -> Prepped end end. -spec encode(jid() | ljid()) -> binary(). encode(J) -> to_string(J). -spec to_string(jid() | ljid()) -> binary(). to_string(#jid{user = User, server = Server, resource = Resource}) -> to_string({User, Server, Resource}); to_string({N, S, R}) -> Node = iolist_to_binary(N), Server = iolist_to_binary(S), Resource = iolist_to_binary(R), S1 = case Node of <<"">> -> <<"">>; _ -> <> end, S2 = <>, S3 = case Resource of <<"">> -> S2; _ -> <> end, S3. -spec is_nodename(binary()) -> boolean(). is_nodename(Node) -> N = nodeprep(Node), (N /= error) and (N /= <<>>). -define(LOWER(Char), if Char >= $A, Char =< $Z -> Char + 32; true -> Char end). -spec nodeprep(binary()) -> binary() | error. nodeprep("") -> <<>>; nodeprep(S) when byte_size(S) < 1024 -> R = stringprep:nodeprep(S), if byte_size(R) < 1024 -> R; true -> error end; nodeprep(_) -> error. -spec nameprep(binary()) -> binary() | error. nameprep(S) when byte_size(S) < 1024 -> R = stringprep:nameprep(S), if byte_size(R) < 1024 -> R; true -> error end; nameprep(_) -> error. -spec resourceprep(binary()) -> binary() | error. resourceprep(S) when byte_size(S) < 1024 -> R = stringprep:resourceprep(S), if byte_size(R) < 1024 -> R; true -> error end; resourceprep(_) -> error. -spec tolower(jid()) -> ljid(); (ljid()) -> error | ljid(). tolower(#jid{luser = U, lserver = S, lresource = R}) -> {U, S, R}; tolower({U, S, R}) -> case nodeprep(U) of error -> error; LUser -> case nameprep(S) of error -> error; LServer -> case resourceprep(R) of error -> error; LResource -> {LUser, LServer, LResource} end end end. -spec remove_resource(jid()) -> jid(); (ljid()) -> ljid(). remove_resource(#jid{} = JID) -> JID#jid{resource = <<"">>, lresource = <<"">>}; remove_resource({U, S, _R}) -> {U, S, <<"">>}. -spec replace_resource(jid(), binary()) -> error | jid(). replace_resource(JID, Resource) -> case resourceprep(Resource) of error -> error; LResource -> JID#jid{resource = Resource, lresource = LResource} end. %%%=================================================================== %%% Internal functions %%%=================================================================== xmpp-1.4.4/src/xep0280.erl0000644000232200023220000001553513610066730015466 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0280). -compile(export_all). do_decode(<<"sent">>, <<"urn:xmpp:carbons:2">>, El, Opts) -> decode_carbons_sent(<<"urn:xmpp:carbons:2">>, Opts, El); do_decode(<<"received">>, <<"urn:xmpp:carbons:2">>, El, Opts) -> decode_carbons_received(<<"urn:xmpp:carbons:2">>, Opts, El); do_decode(<<"private">>, <<"urn:xmpp:carbons:2">>, El, Opts) -> decode_carbons_private(<<"urn:xmpp:carbons:2">>, Opts, El); do_decode(<<"enable">>, <<"urn:xmpp:carbons:2">>, El, Opts) -> decode_carbons_enable(<<"urn:xmpp:carbons:2">>, Opts, El); do_decode(<<"disable">>, <<"urn:xmpp:carbons:2">>, El, Opts) -> decode_carbons_disable(<<"urn:xmpp:carbons:2">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"sent">>, <<"urn:xmpp:carbons:2">>}, {<<"received">>, <<"urn:xmpp:carbons:2">>}, {<<"private">>, <<"urn:xmpp:carbons:2">>}, {<<"enable">>, <<"urn:xmpp:carbons:2">>}, {<<"disable">>, <<"urn:xmpp:carbons:2">>}]. do_encode({carbons_disable} = Disable, TopXMLNS) -> encode_carbons_disable(Disable, TopXMLNS); do_encode({carbons_enable} = Enable, TopXMLNS) -> encode_carbons_enable(Enable, TopXMLNS); do_encode({carbons_private} = Private, TopXMLNS) -> encode_carbons_private(Private, TopXMLNS); do_encode({carbons_received, _} = Received, TopXMLNS) -> encode_carbons_received(Received, TopXMLNS); do_encode({carbons_sent, _} = Sent, TopXMLNS) -> encode_carbons_sent(Sent, TopXMLNS). do_get_name({carbons_disable}) -> <<"disable">>; do_get_name({carbons_enable}) -> <<"enable">>; do_get_name({carbons_private}) -> <<"private">>; do_get_name({carbons_received, _}) -> <<"received">>; do_get_name({carbons_sent, _}) -> <<"sent">>. do_get_ns({carbons_disable}) -> <<"urn:xmpp:carbons:2">>; do_get_ns({carbons_enable}) -> <<"urn:xmpp:carbons:2">>; do_get_ns({carbons_private}) -> <<"urn:xmpp:carbons:2">>; do_get_ns({carbons_received, _}) -> <<"urn:xmpp:carbons:2">>; do_get_ns({carbons_sent, _}) -> <<"urn:xmpp:carbons:2">>. pp(carbons_disable, 0) -> []; pp(carbons_enable, 0) -> []; pp(carbons_private, 0) -> []; pp(carbons_received, 1) -> [forwarded]; pp(carbons_sent, 1) -> [forwarded]; pp(_, _) -> no. records() -> [{carbons_disable, 0}, {carbons_enable, 0}, {carbons_private, 0}, {carbons_received, 1}, {carbons_sent, 1}]. decode_carbons_sent(__TopXMLNS, __Opts, {xmlel, <<"sent">>, _attrs, _els}) -> Forwarded = decode_carbons_sent_els(__TopXMLNS, __Opts, _els, error), {carbons_sent, Forwarded}. decode_carbons_sent_els(__TopXMLNS, __Opts, [], Forwarded) -> case Forwarded of error -> erlang:error({xmpp_codec, {missing_tag, <<"forwarded">>, __TopXMLNS}}); {value, Forwarded1} -> Forwarded1 end; decode_carbons_sent_els(__TopXMLNS, __Opts, [{xmlel, <<"forwarded">>, _attrs, _} = _el | _els], Forwarded) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:forward:0">> -> decode_carbons_sent_els(__TopXMLNS, __Opts, _els, {value, xep0297:decode_forwarded(<<"urn:xmpp:forward:0">>, __Opts, _el)}); _ -> decode_carbons_sent_els(__TopXMLNS, __Opts, _els, Forwarded) end; decode_carbons_sent_els(__TopXMLNS, __Opts, [_ | _els], Forwarded) -> decode_carbons_sent_els(__TopXMLNS, __Opts, _els, Forwarded). encode_carbons_sent({carbons_sent, Forwarded}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:carbons:2">>, [], __TopXMLNS), _els = lists:reverse('encode_carbons_sent_$forwarded'(Forwarded, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"sent">>, _attrs, _els}. 'encode_carbons_sent_$forwarded'(Forwarded, __TopXMLNS, _acc) -> [xep0297:encode_forwarded(Forwarded, __TopXMLNS) | _acc]. decode_carbons_received(__TopXMLNS, __Opts, {xmlel, <<"received">>, _attrs, _els}) -> Forwarded = decode_carbons_received_els(__TopXMLNS, __Opts, _els, error), {carbons_received, Forwarded}. decode_carbons_received_els(__TopXMLNS, __Opts, [], Forwarded) -> case Forwarded of error -> erlang:error({xmpp_codec, {missing_tag, <<"forwarded">>, __TopXMLNS}}); {value, Forwarded1} -> Forwarded1 end; decode_carbons_received_els(__TopXMLNS, __Opts, [{xmlel, <<"forwarded">>, _attrs, _} = _el | _els], Forwarded) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:forward:0">> -> decode_carbons_received_els(__TopXMLNS, __Opts, _els, {value, xep0297:decode_forwarded(<<"urn:xmpp:forward:0">>, __Opts, _el)}); _ -> decode_carbons_received_els(__TopXMLNS, __Opts, _els, Forwarded) end; decode_carbons_received_els(__TopXMLNS, __Opts, [_ | _els], Forwarded) -> decode_carbons_received_els(__TopXMLNS, __Opts, _els, Forwarded). encode_carbons_received({carbons_received, Forwarded}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:carbons:2">>, [], __TopXMLNS), _els = lists:reverse('encode_carbons_received_$forwarded'(Forwarded, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"received">>, _attrs, _els}. 'encode_carbons_received_$forwarded'(Forwarded, __TopXMLNS, _acc) -> [xep0297:encode_forwarded(Forwarded, __TopXMLNS) | _acc]. decode_carbons_private(__TopXMLNS, __Opts, {xmlel, <<"private">>, _attrs, _els}) -> {carbons_private}. encode_carbons_private({carbons_private}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:carbons:2">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"private">>, _attrs, _els}. decode_carbons_enable(__TopXMLNS, __Opts, {xmlel, <<"enable">>, _attrs, _els}) -> {carbons_enable}. encode_carbons_enable({carbons_enable}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:carbons:2">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"enable">>, _attrs, _els}. decode_carbons_disable(__TopXMLNS, __Opts, {xmlel, <<"disable">>, _attrs, _els}) -> {carbons_disable}. encode_carbons_disable({carbons_disable}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:carbons:2">>, [], __TopXMLNS), _els = [], _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"disable">>, _attrs, _els}. xmpp-1.4.4/src/xep0131.erl0000644000232200023220000001062213610066730015451 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0131). -compile(export_all). do_decode(<<"headers">>, <<"http://jabber.org/protocol/shim">>, El, Opts) -> decode_shim_headers(<<"http://jabber.org/protocol/shim">>, Opts, El); do_decode(<<"header">>, <<"http://jabber.org/protocol/shim">>, El, Opts) -> decode_shim_header(<<"http://jabber.org/protocol/shim">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"headers">>, <<"http://jabber.org/protocol/shim">>}, {<<"header">>, <<"http://jabber.org/protocol/shim">>}]. do_encode({shim, _} = Headers, TopXMLNS) -> encode_shim_headers(Headers, TopXMLNS). do_get_name({shim, _}) -> <<"headers">>. do_get_ns({shim, _}) -> <<"http://jabber.org/protocol/shim">>. pp(shim, 1) -> [headers]; pp(_, _) -> no. records() -> [{shim, 1}]. decode_shim_headers(__TopXMLNS, __Opts, {xmlel, <<"headers">>, _attrs, _els}) -> Headers = decode_shim_headers_els(__TopXMLNS, __Opts, _els, []), {shim, Headers}. decode_shim_headers_els(__TopXMLNS, __Opts, [], Headers) -> lists:reverse(Headers); decode_shim_headers_els(__TopXMLNS, __Opts, [{xmlel, <<"header">>, _attrs, _} = _el | _els], Headers) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/shim">> -> decode_shim_headers_els(__TopXMLNS, __Opts, _els, [decode_shim_header(<<"http://jabber.org/protocol/shim">>, __Opts, _el) | Headers]); _ -> decode_shim_headers_els(__TopXMLNS, __Opts, _els, Headers) end; decode_shim_headers_els(__TopXMLNS, __Opts, [_ | _els], Headers) -> decode_shim_headers_els(__TopXMLNS, __Opts, _els, Headers). encode_shim_headers({shim, Headers}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/shim">>, [], __TopXMLNS), _els = lists:reverse('encode_shim_headers_$headers'(Headers, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"headers">>, _attrs, _els}. 'encode_shim_headers_$headers'([], __TopXMLNS, _acc) -> _acc; 'encode_shim_headers_$headers'([Headers | _els], __TopXMLNS, _acc) -> 'encode_shim_headers_$headers'(_els, __TopXMLNS, [encode_shim_header(Headers, __TopXMLNS) | _acc]). decode_shim_header(__TopXMLNS, __Opts, {xmlel, <<"header">>, _attrs, _els}) -> Cdata = decode_shim_header_els(__TopXMLNS, __Opts, _els, <<>>), Name = decode_shim_header_attrs(__TopXMLNS, _attrs, undefined), {Name, Cdata}. decode_shim_header_els(__TopXMLNS, __Opts, [], Cdata) -> decode_shim_header_cdata(__TopXMLNS, Cdata); decode_shim_header_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_shim_header_els(__TopXMLNS, __Opts, _els, <>); decode_shim_header_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_shim_header_els(__TopXMLNS, __Opts, _els, Cdata). decode_shim_header_attrs(__TopXMLNS, [{<<"name">>, _val} | _attrs], _Name) -> decode_shim_header_attrs(__TopXMLNS, _attrs, _val); decode_shim_header_attrs(__TopXMLNS, [_ | _attrs], Name) -> decode_shim_header_attrs(__TopXMLNS, _attrs, Name); decode_shim_header_attrs(__TopXMLNS, [], Name) -> decode_shim_header_attr_name(__TopXMLNS, Name). encode_shim_header({Name, Cdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"http://jabber.org/protocol/shim">>, [], __TopXMLNS), _els = encode_shim_header_cdata(Cdata, []), _attrs = encode_shim_header_attr_name(Name, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"header">>, _attrs, _els}. decode_shim_header_attr_name(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"name">>, <<"header">>, __TopXMLNS}}); decode_shim_header_attr_name(__TopXMLNS, _val) -> _val. encode_shim_header_attr_name(_val, _acc) -> [{<<"name">>, _val} | _acc]. decode_shim_header_cdata(__TopXMLNS, <<>>) -> <<>>; decode_shim_header_cdata(__TopXMLNS, _val) -> _val. encode_shim_header_cdata(<<>>, _acc) -> _acc; encode_shim_header_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. xmpp-1.4.4/src/xmpp_sasl_scram.erl0000644000232200023220000002144213610066730017545 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Stephen Röttger %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -module(xmpp_sasl_scram). -behaviour(xmpp_sasl). -author('stephen.roettger@googlemail.com'). -protocol({rfc, 5802}). -export([mech_new/4, mech_step/2, format_error/1]). -include("scram.hrl"). -type password() :: binary() | #scram{}. -type get_password_fun() :: fun((binary()) -> {false | password(), module()}). -record(state, {step = 2 :: 2 | 4, stored_key = <<"">> :: binary(), server_key = <<"">> :: binary(), username = <<"">> :: binary(), auth_module :: module(), get_password :: get_password_fun(), auth_message = <<"">> :: binary(), client_nonce = <<"">> :: binary(), server_nonce = <<"">> :: binary()}). -define(SALT_LENGTH, 16). -define(NONCE_LENGTH, 16). -type error_reason() :: unsupported_extension | bad_username | not_authorized | saslprep_failed | parser_failed | bad_attribute | nonce_mismatch | bad_channel_binding. -export_type([error_reason/0]). -spec format_error(error_reason()) -> {atom(), binary()}. format_error(unsupported_extension) -> {'bad-protocol', <<"Unsupported extension">>}; format_error(bad_username) -> {'invalid-authzid', <<"Malformed username">>}; format_error(not_authorized) -> {'not-authorized', <<"Invalid username or password">>}; format_error(saslprep_failed) -> {'not-authorized', <<"SASLprep failed">>}; format_error(parser_failed) -> {'bad-protocol', <<"Response decoding failed">>}; format_error(bad_attribute) -> {'bad-protocol', <<"Malformed or unexpected attribute">>}; format_error(nonce_mismatch) -> {'bad-protocol', <<"Nonce mismatch">>}; format_error(bad_channel_binding) -> {'bad-protocol', <<"Invalid channel binding">>}. mech_new(_Host, GetPassword, _CheckPassword, _CheckPasswordDigest) -> #state{step = 2, get_password = GetPassword}. mech_step(#state{step = 2} = State, ClientIn) -> case re:split(ClientIn, <<",">>, [{return, binary}]) of [_CBind, _AuthorizationIdentity, _UserNameAttribute, _ClientNonceAttribute, ExtensionAttribute | _] when ExtensionAttribute /= <<"">> -> {error, unsupported_extension}; [CBind, _AuthorizationIdentity, UserNameAttribute, ClientNonceAttribute | _] when (CBind == <<"y">>) or (CBind == <<"n">>) -> case parse_attribute(UserNameAttribute) of {error, Reason} -> {error, Reason}; {_, EscapedUserName} -> case unescape_username(EscapedUserName) of error -> {error, bad_username}; UserName -> case parse_attribute(ClientNonceAttribute) of {$r, ClientNonce} -> {Pass, AuthModule} = (State#state.get_password)(UserName), LPass = if is_binary(Pass) -> jid:resourceprep(Pass); true -> Pass end, if Pass == false -> {error, not_authorized, UserName}; LPass == error -> {error, saslprep_failed, UserName}; true -> {StoredKey, ServerKey, Salt, IterationCount} = if is_record(Pass, scram) -> {base64:decode(Pass#scram.storedkey), base64:decode(Pass#scram.serverkey), base64:decode(Pass#scram.salt), Pass#scram.iterationcount}; true -> TempSalt = p1_rand:bytes(?SALT_LENGTH), SaltedPassword = scram:salted_password(Pass, TempSalt, ?SCRAM_DEFAULT_ITERATION_COUNT), {scram:stored_key(scram:client_key(SaltedPassword)), scram:server_key(SaltedPassword), TempSalt, ?SCRAM_DEFAULT_ITERATION_COUNT} end, ClientFirstMessageBare = substr(ClientIn, str(ClientIn, <<"n=">>)), ServerNonce = base64:encode(p1_rand:bytes(?NONCE_LENGTH)), ServerFirstMessage = iolist_to_binary( ["r=", ClientNonce, ServerNonce, ",", "s=", base64:encode(Salt), ",", "i=", integer_to_list(IterationCount)]), {continue, ServerFirstMessage, State#state{step = 4, stored_key = StoredKey, server_key = ServerKey, auth_module = AuthModule, auth_message = <>, client_nonce = ClientNonce, server_nonce = ServerNonce, username = UserName}} end; _ -> {error, bad_attribute} end end end; _Else -> {error, parser_failed} end; mech_step(#state{step = 4} = State, ClientIn) -> case tokens(ClientIn, <<",">>) of [GS2ChannelBindingAttribute, NonceAttribute, ClientProofAttribute] -> case parse_attribute(GS2ChannelBindingAttribute) of {$c, CVal} -> ChannelBindingSupport = try binary:first(base64:decode(CVal)) catch _:badarg -> 0 end, if (ChannelBindingSupport == $n) or (ChannelBindingSupport == $y) -> Nonce = <<(State#state.client_nonce)/binary, (State#state.server_nonce)/binary>>, case parse_attribute(NonceAttribute) of {$r, CompareNonce} when CompareNonce == Nonce -> case parse_attribute(ClientProofAttribute) of {$p, ClientProofB64} -> ClientProof = try base64:decode(ClientProofB64) catch _:badarg -> <<>> end, AuthMessage = iolist_to_binary( [State#state.auth_message, ",", substr(ClientIn, 1, str(ClientIn, <<",p=">>) - 1)]), ClientSignature = scram:client_signature(State#state.stored_key, AuthMessage), ClientKey = scram:client_key(ClientProof, ClientSignature), CompareStoredKey = scram:stored_key(ClientKey), if CompareStoredKey == State#state.stored_key -> ServerSignature = scram:server_signature(State#state.server_key, AuthMessage), {ok, [{username, State#state.username}, {auth_module, State#state.auth_module}, {authzid, State#state.username}], <<"v=", (base64:encode(ServerSignature))/binary>>}; true -> {error, not_authorized, State#state.username} end; _ -> {error, bad_attribute} end; {$r, _} -> {error, nonce_mismatch}; _ -> {error, bad_attribute} end; true -> {error, bad_channel_binding} end; _ -> {error, bad_attribute} end; _ -> {error, parser_failed} end. parse_attribute(<>) when Val /= <<>> -> case is_alpha(Name) of true -> {Name, Val}; false -> {error, bad_attribute} end; parse_attribute(_) -> {error, bad_attribute}. unescape_username(<<"">>) -> <<"">>; unescape_username(EscapedUsername) -> Pos = str(EscapedUsername, <<"=">>), if Pos == 0 -> EscapedUsername; true -> Start = substr(EscapedUsername, 1, Pos - 1), End = substr(EscapedUsername, Pos), EndLen = byte_size(End), if EndLen < 3 -> error; true -> case substr(End, 1, 3) of <<"=2C">> -> <>; <<"=3D">> -> < {atom(), binary()}. format_error(parser_failed) -> {'bad-protocol', <<"Response decoding failed">>}; format_error(not_authorized) -> {'not-authorized', <<"Invalid username or password">>}. mech_new(_Host, _GetPassword, CheckPassword, _CheckPasswordDigest) -> #state{check_password = CheckPassword}. mech_step(State, ClientIn) -> case prepare(ClientIn) of {AuthzId, User, Password} -> case (State#state.check_password)(User, AuthzId, Password) of {true, AuthModule} -> {ok, [{username, User}, {authzid, AuthzId}, {auth_module, AuthModule}]}; _ -> {error, not_authorized, User} end; error -> {error, parser_failed} end. -spec prepare(binary()) -> {binary(), binary(), binary()} | error. prepare(ClientIn) -> case parse(ClientIn) of [<<"">>, UserMaybeDomain, Password] -> case parse_authzid(UserMaybeDomain) of {ok, User} -> {User, User, Password}; _ -> error end; [AuthzId, User, Password] -> case parse_authzid(AuthzId) of {ok, AuthzUser} -> {AuthzUser, User, Password}; _ -> error end; _ -> error end. -spec parse(binary()) -> [binary()]. parse(S) -> binary:split(S, <<0>>, [global]). -spec parse_authzid(binary()) -> {ok, binary()} | error. parse_authzid(S) -> case binary:split(S, <<$@>>) of [User] -> {ok, User}; [User, _Domain] -> {ok, User}; _ -> error end. xmpp-1.4.4/src/xep0313.erl0000644000232200023220000011355513610066730015464 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0313). -compile(export_all). do_decode(<<"fin">>, <<"urn:xmpp:mam:0">>, El, Opts) -> decode_mam_fin(<<"urn:xmpp:mam:0">>, Opts, El); do_decode(<<"fin">>, <<"urn:xmpp:mam:1">>, El, Opts) -> decode_mam_fin(<<"urn:xmpp:mam:1">>, Opts, El); do_decode(<<"fin">>, <<"urn:xmpp:mam:2">>, El, Opts) -> decode_mam_fin(<<"urn:xmpp:mam:2">>, Opts, El); do_decode(<<"prefs">>, <<"urn:xmpp:mam:0">>, El, Opts) -> decode_mam_prefs(<<"urn:xmpp:mam:0">>, Opts, El); do_decode(<<"prefs">>, <<"urn:xmpp:mam:1">>, El, Opts) -> decode_mam_prefs(<<"urn:xmpp:mam:1">>, Opts, El); do_decode(<<"prefs">>, <<"urn:xmpp:mam:2">>, El, Opts) -> decode_mam_prefs(<<"urn:xmpp:mam:2">>, Opts, El); do_decode(<<"prefs">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_prefs(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"always">>, <<"urn:xmpp:mam:0">>, El, Opts) -> decode_mam_always(<<"urn:xmpp:mam:0">>, Opts, El); do_decode(<<"always">>, <<"urn:xmpp:mam:1">>, El, Opts) -> decode_mam_always(<<"urn:xmpp:mam:1">>, Opts, El); do_decode(<<"always">>, <<"urn:xmpp:mam:2">>, El, Opts) -> decode_mam_always(<<"urn:xmpp:mam:2">>, Opts, El); do_decode(<<"always">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_always(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"never">>, <<"urn:xmpp:mam:0">>, El, Opts) -> decode_mam_never(<<"urn:xmpp:mam:0">>, Opts, El); do_decode(<<"never">>, <<"urn:xmpp:mam:1">>, El, Opts) -> decode_mam_never(<<"urn:xmpp:mam:1">>, Opts, El); do_decode(<<"never">>, <<"urn:xmpp:mam:2">>, El, Opts) -> decode_mam_never(<<"urn:xmpp:mam:2">>, Opts, El); do_decode(<<"never">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_never(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"jid">>, <<"urn:xmpp:mam:0">>, El, Opts) -> decode_mam_jid(<<"urn:xmpp:mam:0">>, Opts, El); do_decode(<<"jid">>, <<"urn:xmpp:mam:1">>, El, Opts) -> decode_mam_jid(<<"urn:xmpp:mam:1">>, Opts, El); do_decode(<<"jid">>, <<"urn:xmpp:mam:2">>, El, Opts) -> decode_mam_jid(<<"urn:xmpp:mam:2">>, Opts, El); do_decode(<<"jid">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_jid(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"result">>, <<"urn:xmpp:mam:0">>, El, Opts) -> decode_mam_result(<<"urn:xmpp:mam:0">>, Opts, El); do_decode(<<"result">>, <<"urn:xmpp:mam:1">>, El, Opts) -> decode_mam_result(<<"urn:xmpp:mam:1">>, Opts, El); do_decode(<<"result">>, <<"urn:xmpp:mam:2">>, El, Opts) -> decode_mam_result(<<"urn:xmpp:mam:2">>, Opts, El); do_decode(<<"result">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_result(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"archived">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_archived(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"query">>, <<"urn:xmpp:mam:0">>, El, Opts) -> decode_mam_query(<<"urn:xmpp:mam:0">>, Opts, El); do_decode(<<"query">>, <<"urn:xmpp:mam:1">>, El, Opts) -> decode_mam_query(<<"urn:xmpp:mam:1">>, Opts, El); do_decode(<<"query">>, <<"urn:xmpp:mam:2">>, El, Opts) -> decode_mam_query(<<"urn:xmpp:mam:2">>, Opts, El); do_decode(<<"query">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_query(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"withtext">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_withtext(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"with">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_with(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"end">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_end(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(<<"start">>, <<"urn:xmpp:mam:tmp">>, El, Opts) -> decode_mam_start(<<"urn:xmpp:mam:tmp">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"fin">>, <<"urn:xmpp:mam:0">>}, {<<"fin">>, <<"urn:xmpp:mam:1">>}, {<<"fin">>, <<"urn:xmpp:mam:2">>}, {<<"prefs">>, <<"urn:xmpp:mam:0">>}, {<<"prefs">>, <<"urn:xmpp:mam:1">>}, {<<"prefs">>, <<"urn:xmpp:mam:2">>}, {<<"prefs">>, <<"urn:xmpp:mam:tmp">>}, {<<"always">>, <<"urn:xmpp:mam:0">>}, {<<"always">>, <<"urn:xmpp:mam:1">>}, {<<"always">>, <<"urn:xmpp:mam:2">>}, {<<"always">>, <<"urn:xmpp:mam:tmp">>}, {<<"never">>, <<"urn:xmpp:mam:0">>}, {<<"never">>, <<"urn:xmpp:mam:1">>}, {<<"never">>, <<"urn:xmpp:mam:2">>}, {<<"never">>, <<"urn:xmpp:mam:tmp">>}, {<<"jid">>, <<"urn:xmpp:mam:0">>}, {<<"jid">>, <<"urn:xmpp:mam:1">>}, {<<"jid">>, <<"urn:xmpp:mam:2">>}, {<<"jid">>, <<"urn:xmpp:mam:tmp">>}, {<<"result">>, <<"urn:xmpp:mam:0">>}, {<<"result">>, <<"urn:xmpp:mam:1">>}, {<<"result">>, <<"urn:xmpp:mam:2">>}, {<<"result">>, <<"urn:xmpp:mam:tmp">>}, {<<"archived">>, <<"urn:xmpp:mam:tmp">>}, {<<"query">>, <<"urn:xmpp:mam:0">>}, {<<"query">>, <<"urn:xmpp:mam:1">>}, {<<"query">>, <<"urn:xmpp:mam:2">>}, {<<"query">>, <<"urn:xmpp:mam:tmp">>}, {<<"withtext">>, <<"urn:xmpp:mam:tmp">>}, {<<"with">>, <<"urn:xmpp:mam:tmp">>}, {<<"end">>, <<"urn:xmpp:mam:tmp">>}, {<<"start">>, <<"urn:xmpp:mam:tmp">>}]. do_encode({mam_query, _, _, _, _, _, _, _, _} = Query, TopXMLNS) -> encode_mam_query(Query, TopXMLNS); do_encode({mam_archived, _, _} = Archived, TopXMLNS) -> encode_mam_archived(Archived, TopXMLNS); do_encode({mam_result, _, _, _, _} = Result, TopXMLNS) -> encode_mam_result(Result, TopXMLNS); do_encode({mam_prefs, _, _, _, _} = Prefs, TopXMLNS) -> encode_mam_prefs(Prefs, TopXMLNS); do_encode({mam_fin, _, _, _, _, _} = Fin, TopXMLNS) -> encode_mam_fin(Fin, TopXMLNS). do_get_name({mam_archived, _, _}) -> <<"archived">>; do_get_name({mam_fin, _, _, _, _, _}) -> <<"fin">>; do_get_name({mam_prefs, _, _, _, _}) -> <<"prefs">>; do_get_name({mam_query, _, _, _, _, _, _, _, _}) -> <<"query">>; do_get_name({mam_result, _, _, _, _}) -> <<"result">>. do_get_ns({mam_archived, _, _}) -> <<"urn:xmpp:mam:tmp">>; do_get_ns({mam_fin, Xmlns, _, _, _, _}) -> Xmlns; do_get_ns({mam_prefs, Xmlns, _, _, _}) -> Xmlns; do_get_ns({mam_query, Xmlns, _, _, _, _, _, _, _}) -> Xmlns; do_get_ns({mam_result, Xmlns, _, _, _}) -> Xmlns. get_els({mam_result, _xmlns, _queryid, _id, _sub_els}) -> _sub_els. set_els({mam_result, _xmlns, _queryid, _id, _}, _sub_els) -> {mam_result, _xmlns, _queryid, _id, _sub_els}. pp(mam_query, 8) -> [xmlns, id, start, 'end', with, withtext, rsm, xdata]; pp(mam_archived, 2) -> [by, id]; pp(mam_result, 4) -> [xmlns, queryid, id, sub_els]; pp(mam_prefs, 4) -> [xmlns, default, always, never]; pp(mam_fin, 5) -> [xmlns, id, rsm, stable, complete]; pp(_, _) -> no. records() -> [{mam_query, 8}, {mam_archived, 2}, {mam_result, 4}, {mam_prefs, 4}, {mam_fin, 5}]. dec_bool(<<"false">>) -> false; dec_bool(<<"0">>) -> false; dec_bool(<<"true">>) -> true; dec_bool(<<"1">>) -> true. dec_enum(Val, Enums) -> AtomVal = erlang:binary_to_existing_atom(Val, utf8), case lists:member(AtomVal, Enums) of true -> AtomVal end. dec_utc(Val) -> xmpp_util:decode_timestamp(Val). enc_bool(false) -> <<"false">>; enc_bool(true) -> <<"true">>. enc_enum(Atom) -> erlang:atom_to_binary(Atom, utf8). enc_utc(Val) -> xmpp_util:encode_timestamp(Val). decode_mam_fin(__TopXMLNS, __Opts, {xmlel, <<"fin">>, _attrs, _els}) -> Rsm = decode_mam_fin_els(__TopXMLNS, __Opts, _els, undefined), {Id, Xmlns, Stable, Complete} = decode_mam_fin_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined, undefined), {mam_fin, Xmlns, Id, Rsm, Stable, Complete}. decode_mam_fin_els(__TopXMLNS, __Opts, [], Rsm) -> Rsm; decode_mam_fin_els(__TopXMLNS, __Opts, [{xmlel, <<"set">>, _attrs, _} = _el | _els], Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_mam_fin_els(__TopXMLNS, __Opts, _els, xep0059:decode_rsm_set(<<"http://jabber.org/protocol/rsm">>, __Opts, _el)); _ -> decode_mam_fin_els(__TopXMLNS, __Opts, _els, Rsm) end; decode_mam_fin_els(__TopXMLNS, __Opts, [_ | _els], Rsm) -> decode_mam_fin_els(__TopXMLNS, __Opts, _els, Rsm). decode_mam_fin_attrs(__TopXMLNS, [{<<"queryid">>, _val} | _attrs], _Id, Xmlns, Stable, Complete) -> decode_mam_fin_attrs(__TopXMLNS, _attrs, _val, Xmlns, Stable, Complete); decode_mam_fin_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Id, _Xmlns, Stable, Complete) -> decode_mam_fin_attrs(__TopXMLNS, _attrs, Id, _val, Stable, Complete); decode_mam_fin_attrs(__TopXMLNS, [{<<"stable">>, _val} | _attrs], Id, Xmlns, _Stable, Complete) -> decode_mam_fin_attrs(__TopXMLNS, _attrs, Id, Xmlns, _val, Complete); decode_mam_fin_attrs(__TopXMLNS, [{<<"complete">>, _val} | _attrs], Id, Xmlns, Stable, _Complete) -> decode_mam_fin_attrs(__TopXMLNS, _attrs, Id, Xmlns, Stable, _val); decode_mam_fin_attrs(__TopXMLNS, [_ | _attrs], Id, Xmlns, Stable, Complete) -> decode_mam_fin_attrs(__TopXMLNS, _attrs, Id, Xmlns, Stable, Complete); decode_mam_fin_attrs(__TopXMLNS, [], Id, Xmlns, Stable, Complete) -> {decode_mam_fin_attr_queryid(__TopXMLNS, Id), decode_mam_fin_attr_xmlns(__TopXMLNS, Xmlns), decode_mam_fin_attr_stable(__TopXMLNS, Stable), decode_mam_fin_attr_complete(__TopXMLNS, Complete)}. encode_mam_fin({mam_fin, Xmlns, Id, Rsm, Stable, Complete}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>], __TopXMLNS), _els = lists:reverse('encode_mam_fin_$rsm'(Rsm, __NewTopXMLNS, [])), _attrs = encode_mam_fin_attr_complete(Complete, encode_mam_fin_attr_stable(Stable, encode_mam_fin_attr_queryid(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)))), {xmlel, <<"fin">>, _attrs, _els}. 'encode_mam_fin_$rsm'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_fin_$rsm'(Rsm, __TopXMLNS, _acc) -> [xep0059:encode_rsm_set(Rsm, __TopXMLNS) | _acc]. decode_mam_fin_attr_queryid(__TopXMLNS, undefined) -> <<>>; decode_mam_fin_attr_queryid(__TopXMLNS, _val) -> _val. encode_mam_fin_attr_queryid(<<>>, _acc) -> _acc; encode_mam_fin_attr_queryid(_val, _acc) -> [{<<"queryid">>, _val} | _acc]. decode_mam_fin_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_mam_fin_attr_xmlns(__TopXMLNS, _val) -> _val. decode_mam_fin_attr_stable(__TopXMLNS, undefined) -> undefined; decode_mam_fin_attr_stable(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"stable">>, <<"fin">>, __TopXMLNS}}); _res -> _res end. encode_mam_fin_attr_stable(undefined, _acc) -> _acc; encode_mam_fin_attr_stable(_val, _acc) -> [{<<"stable">>, enc_bool(_val)} | _acc]. decode_mam_fin_attr_complete(__TopXMLNS, undefined) -> undefined; decode_mam_fin_attr_complete(__TopXMLNS, _val) -> case catch dec_bool(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"complete">>, <<"fin">>, __TopXMLNS}}); _res -> _res end. encode_mam_fin_attr_complete(undefined, _acc) -> _acc; encode_mam_fin_attr_complete(_val, _acc) -> [{<<"complete">>, enc_bool(_val)} | _acc]. decode_mam_prefs(__TopXMLNS, __Opts, {xmlel, <<"prefs">>, _attrs, _els}) -> {Never, Always} = decode_mam_prefs_els(__TopXMLNS, __Opts, _els, undefined, undefined), {Default, Xmlns} = decode_mam_prefs_attrs(__TopXMLNS, _attrs, undefined, undefined), {mam_prefs, Xmlns, Default, Always, Never}. decode_mam_prefs_els(__TopXMLNS, __Opts, [], Never, Always) -> {Never, Always}; decode_mam_prefs_els(__TopXMLNS, __Opts, [{xmlel, <<"always">>, _attrs, _} = _el | _els], Never, Always) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:0">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, Never, decode_mam_always(<<"urn:xmpp:mam:0">>, __Opts, _el)); <<"urn:xmpp:mam:1">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, Never, decode_mam_always(<<"urn:xmpp:mam:1">>, __Opts, _el)); <<"urn:xmpp:mam:2">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, Never, decode_mam_always(<<"urn:xmpp:mam:2">>, __Opts, _el)); <<"urn:xmpp:mam:tmp">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, Never, decode_mam_always(<<"urn:xmpp:mam:tmp">>, __Opts, _el)); _ -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, Never, Always) end; decode_mam_prefs_els(__TopXMLNS, __Opts, [{xmlel, <<"never">>, _attrs, _} = _el | _els], Never, Always) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:0">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, decode_mam_never(<<"urn:xmpp:mam:0">>, __Opts, _el), Always); <<"urn:xmpp:mam:1">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, decode_mam_never(<<"urn:xmpp:mam:1">>, __Opts, _el), Always); <<"urn:xmpp:mam:2">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, decode_mam_never(<<"urn:xmpp:mam:2">>, __Opts, _el), Always); <<"urn:xmpp:mam:tmp">> -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, decode_mam_never(<<"urn:xmpp:mam:tmp">>, __Opts, _el), Always); _ -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, Never, Always) end; decode_mam_prefs_els(__TopXMLNS, __Opts, [_ | _els], Never, Always) -> decode_mam_prefs_els(__TopXMLNS, __Opts, _els, Never, Always). decode_mam_prefs_attrs(__TopXMLNS, [{<<"default">>, _val} | _attrs], _Default, Xmlns) -> decode_mam_prefs_attrs(__TopXMLNS, _attrs, _val, Xmlns); decode_mam_prefs_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Default, _Xmlns) -> decode_mam_prefs_attrs(__TopXMLNS, _attrs, Default, _val); decode_mam_prefs_attrs(__TopXMLNS, [_ | _attrs], Default, Xmlns) -> decode_mam_prefs_attrs(__TopXMLNS, _attrs, Default, Xmlns); decode_mam_prefs_attrs(__TopXMLNS, [], Default, Xmlns) -> {decode_mam_prefs_attr_default(__TopXMLNS, Default), decode_mam_prefs_attr_xmlns(__TopXMLNS, Xmlns)}. encode_mam_prefs({mam_prefs, Xmlns, Default, Always, Never}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], __TopXMLNS), _els = lists:reverse('encode_mam_prefs_$never'(Never, __NewTopXMLNS, 'encode_mam_prefs_$always'(Always, __NewTopXMLNS, []))), _attrs = encode_mam_prefs_attr_default(Default, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"prefs">>, _attrs, _els}. 'encode_mam_prefs_$never'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_prefs_$never'(Never, __TopXMLNS, _acc) -> [encode_mam_never(Never, __TopXMLNS) | _acc]. 'encode_mam_prefs_$always'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_prefs_$always'(Always, __TopXMLNS, _acc) -> [encode_mam_always(Always, __TopXMLNS) | _acc]. decode_mam_prefs_attr_default(__TopXMLNS, undefined) -> undefined; decode_mam_prefs_attr_default(__TopXMLNS, _val) -> case catch dec_enum(_val, [always, never, roster]) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"default">>, <<"prefs">>, __TopXMLNS}}); _res -> _res end. encode_mam_prefs_attr_default(undefined, _acc) -> _acc; encode_mam_prefs_attr_default(_val, _acc) -> [{<<"default">>, enc_enum(_val)} | _acc]. decode_mam_prefs_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_mam_prefs_attr_xmlns(__TopXMLNS, _val) -> _val. decode_mam_always(__TopXMLNS, __Opts, {xmlel, <<"always">>, _attrs, _els}) -> Jids = decode_mam_always_els(__TopXMLNS, __Opts, _els, []), Jids. decode_mam_always_els(__TopXMLNS, __Opts, [], Jids) -> lists:reverse(Jids); decode_mam_always_els(__TopXMLNS, __Opts, [{xmlel, <<"jid">>, _attrs, _} = _el | _els], Jids) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:0">> -> decode_mam_always_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:0">>, __Opts, _el) | Jids]); <<"urn:xmpp:mam:1">> -> decode_mam_always_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:1">>, __Opts, _el) | Jids]); <<"urn:xmpp:mam:2">> -> decode_mam_always_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:2">>, __Opts, _el) | Jids]); <<"urn:xmpp:mam:tmp">> -> decode_mam_always_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:tmp">>, __Opts, _el) | Jids]); _ -> decode_mam_always_els(__TopXMLNS, __Opts, _els, Jids) end; decode_mam_always_els(__TopXMLNS, __Opts, [_ | _els], Jids) -> decode_mam_always_els(__TopXMLNS, __Opts, _els, Jids). encode_mam_always(Jids, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], __TopXMLNS), _els = lists:reverse('encode_mam_always_$jids'(Jids, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"always">>, _attrs, _els}. 'encode_mam_always_$jids'([], __TopXMLNS, _acc) -> _acc; 'encode_mam_always_$jids'([Jids | _els], __TopXMLNS, _acc) -> 'encode_mam_always_$jids'(_els, __TopXMLNS, [encode_mam_jid(Jids, __TopXMLNS) | _acc]). decode_mam_never(__TopXMLNS, __Opts, {xmlel, <<"never">>, _attrs, _els}) -> Jids = decode_mam_never_els(__TopXMLNS, __Opts, _els, []), Jids. decode_mam_never_els(__TopXMLNS, __Opts, [], Jids) -> lists:reverse(Jids); decode_mam_never_els(__TopXMLNS, __Opts, [{xmlel, <<"jid">>, _attrs, _} = _el | _els], Jids) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:0">> -> decode_mam_never_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:0">>, __Opts, _el) | Jids]); <<"urn:xmpp:mam:1">> -> decode_mam_never_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:1">>, __Opts, _el) | Jids]); <<"urn:xmpp:mam:2">> -> decode_mam_never_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:2">>, __Opts, _el) | Jids]); <<"urn:xmpp:mam:tmp">> -> decode_mam_never_els(__TopXMLNS, __Opts, _els, [decode_mam_jid(<<"urn:xmpp:mam:tmp">>, __Opts, _el) | Jids]); _ -> decode_mam_never_els(__TopXMLNS, __Opts, _els, Jids) end; decode_mam_never_els(__TopXMLNS, __Opts, [_ | _els], Jids) -> decode_mam_never_els(__TopXMLNS, __Opts, _els, Jids). encode_mam_never(Jids, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], __TopXMLNS), _els = lists:reverse('encode_mam_never_$jids'(Jids, __NewTopXMLNS, [])), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"never">>, _attrs, _els}. 'encode_mam_never_$jids'([], __TopXMLNS, _acc) -> _acc; 'encode_mam_never_$jids'([Jids | _els], __TopXMLNS, _acc) -> 'encode_mam_never_$jids'(_els, __TopXMLNS, [encode_mam_jid(Jids, __TopXMLNS) | _acc]). decode_mam_jid(__TopXMLNS, __Opts, {xmlel, <<"jid">>, _attrs, _els}) -> Cdata = decode_mam_jid_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mam_jid_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mam_jid_cdata(__TopXMLNS, Cdata); decode_mam_jid_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mam_jid_els(__TopXMLNS, __Opts, _els, <>); decode_mam_jid_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mam_jid_els(__TopXMLNS, __Opts, _els, Cdata). encode_mam_jid(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<>>, [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], __TopXMLNS), _els = encode_mam_jid_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"jid">>, _attrs, _els}. decode_mam_jid_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"jid">>, __TopXMLNS}}); decode_mam_jid_cdata(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"jid">>, __TopXMLNS}}); _res -> _res end. encode_mam_jid_cdata(_val, _acc) -> [{xmlcdata, jid:encode(_val)} | _acc]. decode_mam_result(__TopXMLNS, __Opts, {xmlel, <<"result">>, _attrs, _els}) -> __Els = decode_mam_result_els(__TopXMLNS, __Opts, _els, []), {Queryid, Xmlns, Id} = decode_mam_result_attrs(__TopXMLNS, _attrs, undefined, undefined, undefined), {mam_result, Xmlns, Queryid, Id, __Els}. decode_mam_result_els(__TopXMLNS, __Opts, [], __Els) -> lists:reverse(__Els); decode_mam_result_els(__TopXMLNS, __Opts, [{xmlel, _name, _attrs, _} = _el | _els], __Els) -> case proplists:get_bool(ignore_els, __Opts) of true -> decode_mam_result_els(__TopXMLNS, __Opts, _els, [_el | __Els]); false -> __XMLNS = xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS), case xmpp_codec:get_mod(_name, __XMLNS) of undefined -> decode_mam_result_els(__TopXMLNS, __Opts, _els, [_el | __Els]); Mod -> decode_mam_result_els(__TopXMLNS, __Opts, _els, [Mod:do_decode(_name, __XMLNS, _el, __Opts) | __Els]) end end; decode_mam_result_els(__TopXMLNS, __Opts, [_ | _els], __Els) -> decode_mam_result_els(__TopXMLNS, __Opts, _els, __Els). decode_mam_result_attrs(__TopXMLNS, [{<<"queryid">>, _val} | _attrs], _Queryid, Xmlns, Id) -> decode_mam_result_attrs(__TopXMLNS, _attrs, _val, Xmlns, Id); decode_mam_result_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Queryid, _Xmlns, Id) -> decode_mam_result_attrs(__TopXMLNS, _attrs, Queryid, _val, Id); decode_mam_result_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], Queryid, Xmlns, _Id) -> decode_mam_result_attrs(__TopXMLNS, _attrs, Queryid, Xmlns, _val); decode_mam_result_attrs(__TopXMLNS, [_ | _attrs], Queryid, Xmlns, Id) -> decode_mam_result_attrs(__TopXMLNS, _attrs, Queryid, Xmlns, Id); decode_mam_result_attrs(__TopXMLNS, [], Queryid, Xmlns, Id) -> {decode_mam_result_attr_queryid(__TopXMLNS, Queryid), decode_mam_result_attr_xmlns(__TopXMLNS, Xmlns), decode_mam_result_attr_id(__TopXMLNS, Id)}. encode_mam_result({mam_result, Xmlns, Queryid, Id, __Els}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], __TopXMLNS), _els = [xmpp_codec:encode(_el, __NewTopXMLNS) || _el <- __Els], _attrs = encode_mam_result_attr_id(Id, encode_mam_result_attr_queryid(Queryid, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"result">>, _attrs, _els}. decode_mam_result_attr_queryid(__TopXMLNS, undefined) -> <<>>; decode_mam_result_attr_queryid(__TopXMLNS, _val) -> _val. encode_mam_result_attr_queryid(<<>>, _acc) -> _acc; encode_mam_result_attr_queryid(_val, _acc) -> [{<<"queryid">>, _val} | _acc]. decode_mam_result_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_mam_result_attr_xmlns(__TopXMLNS, _val) -> _val. decode_mam_result_attr_id(__TopXMLNS, undefined) -> <<>>; decode_mam_result_attr_id(__TopXMLNS, _val) -> _val. encode_mam_result_attr_id(<<>>, _acc) -> _acc; encode_mam_result_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_mam_archived(__TopXMLNS, __Opts, {xmlel, <<"archived">>, _attrs, _els}) -> {Id, By} = decode_mam_archived_attrs(__TopXMLNS, _attrs, undefined, undefined), {mam_archived, By, Id}. decode_mam_archived_attrs(__TopXMLNS, [{<<"id">>, _val} | _attrs], _Id, By) -> decode_mam_archived_attrs(__TopXMLNS, _attrs, _val, By); decode_mam_archived_attrs(__TopXMLNS, [{<<"by">>, _val} | _attrs], Id, _By) -> decode_mam_archived_attrs(__TopXMLNS, _attrs, Id, _val); decode_mam_archived_attrs(__TopXMLNS, [_ | _attrs], Id, By) -> decode_mam_archived_attrs(__TopXMLNS, _attrs, Id, By); decode_mam_archived_attrs(__TopXMLNS, [], Id, By) -> {decode_mam_archived_attr_id(__TopXMLNS, Id), decode_mam_archived_attr_by(__TopXMLNS, By)}. encode_mam_archived({mam_archived, By, Id}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mam:tmp">>, [], __TopXMLNS), _els = [], _attrs = encode_mam_archived_attr_by(By, encode_mam_archived_attr_id(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS))), {xmlel, <<"archived">>, _attrs, _els}. decode_mam_archived_attr_id(__TopXMLNS, undefined) -> <<>>; decode_mam_archived_attr_id(__TopXMLNS, _val) -> _val. encode_mam_archived_attr_id(<<>>, _acc) -> _acc; encode_mam_archived_attr_id(_val, _acc) -> [{<<"id">>, _val} | _acc]. decode_mam_archived_attr_by(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"by">>, <<"archived">>, __TopXMLNS}}); decode_mam_archived_attr_by(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_attr_value, <<"by">>, <<"archived">>, __TopXMLNS}}); _res -> _res end. encode_mam_archived_attr_by(_val, _acc) -> [{<<"by">>, jid:encode(_val)} | _acc]. decode_mam_query(__TopXMLNS, __Opts, {xmlel, <<"query">>, _attrs, _els}) -> {Xdata, Withtext, End, Start, With, Rsm} = decode_mam_query_els(__TopXMLNS, __Opts, _els, undefined, undefined, undefined, undefined, undefined, undefined), {Id, Xmlns} = decode_mam_query_attrs(__TopXMLNS, _attrs, undefined, undefined), {mam_query, Xmlns, Id, Start, End, With, Withtext, Rsm, Xdata}. decode_mam_query_els(__TopXMLNS, __Opts, [], Xdata, Withtext, End, Start, With, Rsm) -> {Xdata, Withtext, End, Start, With, Rsm}; decode_mam_query_els(__TopXMLNS, __Opts, [{xmlel, <<"start">>, _attrs, _} = _el | _els], Xdata, Withtext, End, Start, With, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:tmp">> -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, decode_mam_start(<<"urn:xmpp:mam:tmp">>, __Opts, _el), With, Rsm); _ -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, Rsm) end; decode_mam_query_els(__TopXMLNS, __Opts, [{xmlel, <<"end">>, _attrs, _} = _el | _els], Xdata, Withtext, End, Start, With, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:tmp">> -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, decode_mam_end(<<"urn:xmpp:mam:tmp">>, __Opts, _el), Start, With, Rsm); _ -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, Rsm) end; decode_mam_query_els(__TopXMLNS, __Opts, [{xmlel, <<"with">>, _attrs, _} = _el | _els], Xdata, Withtext, End, Start, With, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:tmp">> -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, decode_mam_with(<<"urn:xmpp:mam:tmp">>, __Opts, _el), Rsm); _ -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, Rsm) end; decode_mam_query_els(__TopXMLNS, __Opts, [{xmlel, <<"withtext">>, _attrs, _} = _el | _els], Xdata, Withtext, End, Start, With, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"urn:xmpp:mam:tmp">> -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, decode_mam_withtext(<<"urn:xmpp:mam:tmp">>, __Opts, _el), End, Start, With, Rsm); _ -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, Rsm) end; decode_mam_query_els(__TopXMLNS, __Opts, [{xmlel, <<"set">>, _attrs, _} = _el | _els], Xdata, Withtext, End, Start, With, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"http://jabber.org/protocol/rsm">> -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, xep0059:decode_rsm_set(<<"http://jabber.org/protocol/rsm">>, __Opts, _el)); _ -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, Rsm) end; decode_mam_query_els(__TopXMLNS, __Opts, [{xmlel, <<"x">>, _attrs, _} = _el | _els], Xdata, Withtext, End, Start, With, Rsm) -> case xmpp_codec:get_attr(<<"xmlns">>, _attrs, __TopXMLNS) of <<"jabber:x:data">> -> decode_mam_query_els(__TopXMLNS, __Opts, _els, xep0004:decode_xdata(<<"jabber:x:data">>, __Opts, _el), Withtext, End, Start, With, Rsm); _ -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, Rsm) end; decode_mam_query_els(__TopXMLNS, __Opts, [_ | _els], Xdata, Withtext, End, Start, With, Rsm) -> decode_mam_query_els(__TopXMLNS, __Opts, _els, Xdata, Withtext, End, Start, With, Rsm). decode_mam_query_attrs(__TopXMLNS, [{<<"queryid">>, _val} | _attrs], _Id, Xmlns) -> decode_mam_query_attrs(__TopXMLNS, _attrs, _val, Xmlns); decode_mam_query_attrs(__TopXMLNS, [{<<"xmlns">>, _val} | _attrs], Id, _Xmlns) -> decode_mam_query_attrs(__TopXMLNS, _attrs, Id, _val); decode_mam_query_attrs(__TopXMLNS, [_ | _attrs], Id, Xmlns) -> decode_mam_query_attrs(__TopXMLNS, _attrs, Id, Xmlns); decode_mam_query_attrs(__TopXMLNS, [], Id, Xmlns) -> {decode_mam_query_attr_queryid(__TopXMLNS, Id), decode_mam_query_attr_xmlns(__TopXMLNS, Xmlns)}. encode_mam_query({mam_query, Xmlns, Id, Start, End, With, Withtext, Rsm, Xdata}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(Xmlns, [<<"urn:xmpp:mam:0">>, <<"urn:xmpp:mam:1">>, <<"urn:xmpp:mam:2">>, <<"urn:xmpp:mam:tmp">>], __TopXMLNS), _els = lists:reverse('encode_mam_query_$xdata'(Xdata, __NewTopXMLNS, 'encode_mam_query_$withtext'(Withtext, __NewTopXMLNS, 'encode_mam_query_$end'(End, __NewTopXMLNS, 'encode_mam_query_$start'(Start, __NewTopXMLNS, 'encode_mam_query_$with'(With, __NewTopXMLNS, 'encode_mam_query_$rsm'(Rsm, __NewTopXMLNS, []))))))), _attrs = encode_mam_query_attr_queryid(Id, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"query">>, _attrs, _els}. 'encode_mam_query_$xdata'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_query_$xdata'(Xdata, __TopXMLNS, _acc) -> [xep0004:encode_xdata(Xdata, __TopXMLNS) | _acc]. 'encode_mam_query_$withtext'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_query_$withtext'(Withtext, __TopXMLNS, _acc) -> [encode_mam_withtext(Withtext, __TopXMLNS) | _acc]. 'encode_mam_query_$end'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_query_$end'(End, __TopXMLNS, _acc) -> [encode_mam_end(End, __TopXMLNS) | _acc]. 'encode_mam_query_$start'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_query_$start'(Start, __TopXMLNS, _acc) -> [encode_mam_start(Start, __TopXMLNS) | _acc]. 'encode_mam_query_$with'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_query_$with'(With, __TopXMLNS, _acc) -> [encode_mam_with(With, __TopXMLNS) | _acc]. 'encode_mam_query_$rsm'(undefined, __TopXMLNS, _acc) -> _acc; 'encode_mam_query_$rsm'(Rsm, __TopXMLNS, _acc) -> [xep0059:encode_rsm_set(Rsm, __TopXMLNS) | _acc]. decode_mam_query_attr_queryid(__TopXMLNS, undefined) -> <<>>; decode_mam_query_attr_queryid(__TopXMLNS, _val) -> _val. encode_mam_query_attr_queryid(<<>>, _acc) -> _acc; encode_mam_query_attr_queryid(_val, _acc) -> [{<<"queryid">>, _val} | _acc]. decode_mam_query_attr_xmlns(__TopXMLNS, undefined) -> <<>>; decode_mam_query_attr_xmlns(__TopXMLNS, _val) -> _val. decode_mam_withtext(__TopXMLNS, __Opts, {xmlel, <<"withtext">>, _attrs, _els}) -> Cdata = decode_mam_withtext_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mam_withtext_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mam_withtext_cdata(__TopXMLNS, Cdata); decode_mam_withtext_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mam_withtext_els(__TopXMLNS, __Opts, _els, <>); decode_mam_withtext_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mam_withtext_els(__TopXMLNS, __Opts, _els, Cdata). encode_mam_withtext(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mam:tmp">>, [], __TopXMLNS), _els = encode_mam_withtext_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"withtext">>, _attrs, _els}. decode_mam_withtext_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"withtext">>, __TopXMLNS}}); decode_mam_withtext_cdata(__TopXMLNS, _val) -> _val. encode_mam_withtext_cdata(_val, _acc) -> [{xmlcdata, _val} | _acc]. decode_mam_with(__TopXMLNS, __Opts, {xmlel, <<"with">>, _attrs, _els}) -> Cdata = decode_mam_with_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mam_with_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mam_with_cdata(__TopXMLNS, Cdata); decode_mam_with_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mam_with_els(__TopXMLNS, __Opts, _els, <>); decode_mam_with_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mam_with_els(__TopXMLNS, __Opts, _els, Cdata). encode_mam_with(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mam:tmp">>, [], __TopXMLNS), _els = encode_mam_with_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"with">>, _attrs, _els}. decode_mam_with_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"with">>, __TopXMLNS}}); decode_mam_with_cdata(__TopXMLNS, _val) -> case catch jid:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"with">>, __TopXMLNS}}); _res -> _res end. encode_mam_with_cdata(_val, _acc) -> [{xmlcdata, jid:encode(_val)} | _acc]. decode_mam_end(__TopXMLNS, __Opts, {xmlel, <<"end">>, _attrs, _els}) -> Cdata = decode_mam_end_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mam_end_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mam_end_cdata(__TopXMLNS, Cdata); decode_mam_end_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mam_end_els(__TopXMLNS, __Opts, _els, <>); decode_mam_end_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mam_end_els(__TopXMLNS, __Opts, _els, Cdata). encode_mam_end(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mam:tmp">>, [], __TopXMLNS), _els = encode_mam_end_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"end">>, _attrs, _els}. decode_mam_end_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"end">>, __TopXMLNS}}); decode_mam_end_cdata(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"end">>, __TopXMLNS}}); _res -> _res end. encode_mam_end_cdata(_val, _acc) -> [{xmlcdata, enc_utc(_val)} | _acc]. decode_mam_start(__TopXMLNS, __Opts, {xmlel, <<"start">>, _attrs, _els}) -> Cdata = decode_mam_start_els(__TopXMLNS, __Opts, _els, <<>>), Cdata. decode_mam_start_els(__TopXMLNS, __Opts, [], Cdata) -> decode_mam_start_cdata(__TopXMLNS, Cdata); decode_mam_start_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Cdata) -> decode_mam_start_els(__TopXMLNS, __Opts, _els, <>); decode_mam_start_els(__TopXMLNS, __Opts, [_ | _els], Cdata) -> decode_mam_start_els(__TopXMLNS, __Opts, _els, Cdata). encode_mam_start(Cdata, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:mam:tmp">>, [], __TopXMLNS), _els = encode_mam_start_cdata(Cdata, []), _attrs = xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS), {xmlel, <<"start">>, _attrs, _els}. decode_mam_start_cdata(__TopXMLNS, <<>>) -> erlang:error({xmpp_codec, {missing_cdata, <<>>, <<"start">>, __TopXMLNS}}); decode_mam_start_cdata(__TopXMLNS, _val) -> case catch dec_utc(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"start">>, __TopXMLNS}}); _res -> _res end. encode_mam_start_cdata(_val, _acc) -> [{xmlcdata, enc_utc(_val)} | _acc]. xmpp-1.4.4/src/xep0300.erl0000644000232200023220000001007613610066730015452 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -module(xep0300). -compile(export_all). do_decode(<<"hash-used">>, <<"urn:xmpp:hashes:2">>, El, Opts) -> decode_hash_used(<<"urn:xmpp:hashes:2">>, Opts, El); do_decode(<<"hash">>, <<"urn:xmpp:hashes:2">>, El, Opts) -> decode_hash(<<"urn:xmpp:hashes:2">>, Opts, El); do_decode(Name, <<>>, _, _) -> erlang:error({xmpp_codec, {missing_tag_xmlns, Name}}); do_decode(Name, XMLNS, _, _) -> erlang:error({xmpp_codec, {unknown_tag, Name, XMLNS}}). tags() -> [{<<"hash-used">>, <<"urn:xmpp:hashes:2">>}, {<<"hash">>, <<"urn:xmpp:hashes:2">>}]. do_encode({hash, _, _} = Hash, TopXMLNS) -> encode_hash(Hash, TopXMLNS); do_encode({hash_used, _} = Hash_used, TopXMLNS) -> encode_hash_used(Hash_used, TopXMLNS). do_get_name({hash, _, _}) -> <<"hash">>; do_get_name({hash_used, _}) -> <<"hash-used">>. do_get_ns({hash, _, _}) -> <<"urn:xmpp:hashes:2">>; do_get_ns({hash_used, _}) -> <<"urn:xmpp:hashes:2">>. pp(hash, 2) -> [algo, data]; pp(hash_used, 1) -> [algo]; pp(_, _) -> no. records() -> [{hash, 2}, {hash_used, 1}]. decode_hash_used(__TopXMLNS, __Opts, {xmlel, <<"hash-used">>, _attrs, _els}) -> Algo = decode_hash_used_attrs(__TopXMLNS, _attrs, undefined), {hash_used, Algo}. decode_hash_used_attrs(__TopXMLNS, [{<<"algo">>, _val} | _attrs], _Algo) -> decode_hash_used_attrs(__TopXMLNS, _attrs, _val); decode_hash_used_attrs(__TopXMLNS, [_ | _attrs], Algo) -> decode_hash_used_attrs(__TopXMLNS, _attrs, Algo); decode_hash_used_attrs(__TopXMLNS, [], Algo) -> decode_hash_used_attr_algo(__TopXMLNS, Algo). encode_hash_used({hash_used, Algo}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hashes:2">>, [], __TopXMLNS), _els = [], _attrs = encode_hash_used_attr_algo(Algo, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"hash-used">>, _attrs, _els}. decode_hash_used_attr_algo(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"algo">>, <<"hash-used">>, __TopXMLNS}}); decode_hash_used_attr_algo(__TopXMLNS, _val) -> _val. encode_hash_used_attr_algo(_val, _acc) -> [{<<"algo">>, _val} | _acc]. decode_hash(__TopXMLNS, __Opts, {xmlel, <<"hash">>, _attrs, _els}) -> Data = decode_hash_els(__TopXMLNS, __Opts, _els, <<>>), Algo = decode_hash_attrs(__TopXMLNS, _attrs, undefined), {hash, Algo, Data}. decode_hash_els(__TopXMLNS, __Opts, [], Data) -> decode_hash_cdata(__TopXMLNS, Data); decode_hash_els(__TopXMLNS, __Opts, [{xmlcdata, _data} | _els], Data) -> decode_hash_els(__TopXMLNS, __Opts, _els, <>); decode_hash_els(__TopXMLNS, __Opts, [_ | _els], Data) -> decode_hash_els(__TopXMLNS, __Opts, _els, Data). decode_hash_attrs(__TopXMLNS, [{<<"algo">>, _val} | _attrs], _Algo) -> decode_hash_attrs(__TopXMLNS, _attrs, _val); decode_hash_attrs(__TopXMLNS, [_ | _attrs], Algo) -> decode_hash_attrs(__TopXMLNS, _attrs, Algo); decode_hash_attrs(__TopXMLNS, [], Algo) -> decode_hash_attr_algo(__TopXMLNS, Algo). encode_hash({hash, Algo, Data}, __TopXMLNS) -> __NewTopXMLNS = xmpp_codec:choose_top_xmlns(<<"urn:xmpp:hashes:2">>, [], __TopXMLNS), _els = encode_hash_cdata(Data, []), _attrs = encode_hash_attr_algo(Algo, xmpp_codec:enc_xmlns_attrs(__NewTopXMLNS, __TopXMLNS)), {xmlel, <<"hash">>, _attrs, _els}. decode_hash_attr_algo(__TopXMLNS, undefined) -> erlang:error({xmpp_codec, {missing_attr, <<"algo">>, <<"hash">>, __TopXMLNS}}); decode_hash_attr_algo(__TopXMLNS, _val) -> _val. encode_hash_attr_algo(_val, _acc) -> [{<<"algo">>, _val} | _acc]. decode_hash_cdata(__TopXMLNS, <<>>) -> <<>>; decode_hash_cdata(__TopXMLNS, _val) -> case catch base64:decode(_val) of {'EXIT', _} -> erlang:error({xmpp_codec, {bad_cdata_value, <<>>, <<"hash">>, __TopXMLNS}}); _res -> _res end. encode_hash_cdata(<<>>, _acc) -> _acc; encode_hash_cdata(_val, _acc) -> [{xmlcdata, base64:encode(_val)} | _acc]. xmpp-1.4.4/rebar.config0000644000232200023220000000432413610066730015341 0ustar debalancedebalance%%%---------------------------------------------------------------------- %%% File : rebar.config %%% Author : Evgeniy Khramtsov %%% Purpose : Rebar build script. Compliant with rebar and rebar3. %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%---------------------------------------------------------------------- {erl_opts, [debug_info, {src_dirs, ["asn1", "src"]}, nowarn_export_all, {i, "include"}, {i, "../fast_xml/include"}, {i, "deps/fast_xml/include"}]}. {port_env, [{"CFLAGS", "$CFLAGS"}, {"LDFLAGS", "$LDFLAGS"}]}. {port_specs, [{"priv/lib/jid.so", ["c_src/jid.c"]}, {"priv/lib/xmpp_uri.so", ["c_src/xmpp_uri.c"]}, {"priv/lib/xmpp_lang.so", ["c_src/xmpp_lang.c"]}]}. {deps, [{p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.17"}}}, {fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.38"}}}, {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.1.3"}}}, {ezlib, ".*", {git, "https://github.com/processone/ezlib", {tag, "1.0.6"}}}, {idna, ".*", {git, "https://github.com/benoitc/erlang-idna", {tag, "6.0.0"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.18"}}}]}. {clean_files, ["c_src/jid.gcda", "c_src/jid.gcno"]}. {cover_enabled, true}. {cover_export_enabled, true}. {xref_checks, [undefined_function_calls, undefined_functions, deprecated_function_calls, deprecated_functions]}. {profiles, [{test, [{erl_opts, [{src_dirs, ["src", "test"]}]}]}]}. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: xmpp-1.4.4/CODE_OF_CONDUCT.md0000644000232200023220000000643313610066730015661 0ustar debalancedebalance# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at contact@process-one.net. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq xmpp-1.4.4/include/0000755000232200023220000000000013610066730014477 5ustar debalancedebalancexmpp-1.4.4/include/jid.hrl0000644000232200023220000000240413610066730015754 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% %%% @end %%% Created : 10 Jul 2016 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -record(jid, {user = <<"">> :: binary(), server = <<"">> :: binary(), resource = <<"">> :: binary(), luser = <<"">> :: binary(), lserver = <<"">> :: binary(), lresource = <<"">> :: binary()}). -type(jid() :: #jid{}). -type(ljid() :: {binary(), binary(), binary()}). xmpp-1.4.4/include/pubsub_subscribe_authorization.hrl0000644000232200023220000000176313610066730023536 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_subscribe_authorization.xdata %% Form type: http://jabber.org/protocol/pubsub#subscribe_authorization %% Document: XEP-0060 -type property() :: {'allow', boolean()} | {'node', binary()} | {'subscriber_jid', jid:jid()} | {'subid', binary()}. -type result() :: [property()]. -type form_property() :: {'allow', boolean() | undefined} | {'node', binary()} | {'subscriber_jid', jid:jid() | undefined} | {'subid', binary()}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/pubsub_node_config.hrl0000644000232200023220000001216013610066730021040 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_node_config.xdata %% Form type: http://jabber.org/protocol/pubsub#node_config %% Document: XEP-0060 -type 'access_model'() :: authorize | open | presence | roster | whitelist. -type 'children_association_policy'() :: all | owners | whitelist. -type 'itemreply'() :: owner | publisher | none. -type 'node_type'() :: leaf | collection. -type 'notification_type'() :: normal | headline. -type 'publish_model'() :: publishers | subscribers | open. -type 'send_last_published_item'() :: never | on_sub | on_sub_and_presence. -type property() :: {'access_model', 'access_model'()} | {'body_xslt', binary()} | {'children_association_policy', 'children_association_policy'()} | {'children_association_whitelist', [jid:jid()]} | {'children', [binary()]} | {'children_max', binary()} | {'collection', [binary()]} | {'contact', [jid:jid()]} | {'dataform_xslt', binary()} | {'deliver_notifications', boolean()} | {'deliver_payloads', boolean()} | {'description', binary()} | {'item_expire', binary()} | {'itemreply', 'itemreply'()} | {'language', binary()} | {'max_items', non_neg_integer()} | {'max_payload_size', non_neg_integer()} | {'node_type', 'node_type'()} | {'notification_type', 'notification_type'()} | {'notify_config', boolean()} | {'notify_delete', boolean()} | {'notify_retract', boolean()} | {'notify_sub', boolean()} | {'persist_items', boolean()} | {'presence_based_delivery', boolean()} | {'publish_model', 'publish_model'()} | {'purge_offline', boolean()} | {'roster_groups_allowed', [binary()]} | {'send_last_published_item', 'send_last_published_item'()} | {'tempsub', boolean()} | {'subscribe', boolean()} | {'title', binary()} | {'type', binary()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'access_model', 'access_model'() | undefined} | {'access_model', 'access_model'() | undefined, options('access_model'())} | {'body_xslt', binary()} | {'children_association_policy', 'children_association_policy'() | undefined} | {'children_association_policy', 'children_association_policy'() | undefined, options('children_association_policy'())} | {'children_association_whitelist', [jid:jid()]} | {'children', [binary()]} | {'children_max', binary()} | {'collection', [binary()]} | {'contact', [jid:jid()]} | {'dataform_xslt', binary()} | {'deliver_notifications', boolean() | undefined} | {'deliver_payloads', boolean() | undefined} | {'description', binary()} | {'item_expire', binary()} | {'itemreply', 'itemreply'() | undefined} | {'itemreply', 'itemreply'() | undefined, options('itemreply'())} | {'language', binary()} | {'language', binary(), options(binary())} | {'max_items', non_neg_integer() | undefined} | {'max_payload_size', non_neg_integer() | undefined} | {'node_type', 'node_type'() | undefined} | {'node_type', 'node_type'() | undefined, options('node_type'())} | {'notification_type', 'notification_type'() | undefined} | {'notification_type', 'notification_type'() | undefined, options('notification_type'())} | {'notify_config', boolean() | undefined} | {'notify_delete', boolean() | undefined} | {'notify_retract', boolean() | undefined} | {'notify_sub', boolean() | undefined} | {'persist_items', boolean() | undefined} | {'presence_based_delivery', boolean() | undefined} | {'publish_model', 'publish_model'() | undefined} | {'publish_model', 'publish_model'() | undefined, options('publish_model'())} | {'purge_offline', boolean() | undefined} | {'roster_groups_allowed', [binary()]} | {'roster_groups_allowed', [binary()], options(binary())} | {'send_last_published_item', 'send_last_published_item'() | undefined} | {'send_last_published_item', 'send_last_published_item'() | undefined, options('send_last_published_item'())} | {'tempsub', boolean() | undefined} | {'subscribe', boolean() | undefined} | {'title', binary()} | {'type', binary()}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/muc_register.hrl0000644000232200023220000000221513610066730017676 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_register.xdata %% Form type: http://jabber.org/protocol/muc#register %% Document: XEP-0045 -type property() :: {'allow', boolean()} | {'email', binary()} | {'faqentry', [binary()]} | {'first', binary()} | {'last', binary()} | {'roomnick', binary()} | {'url', binary()}. -type result() :: [property()]. -type form_property() :: {'allow', boolean() | undefined} | {'email', binary()} | {'faqentry', [binary()]} | {'first', binary()} | {'last', binary()} | {'roomnick', binary()} | {'url', binary()}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/pubsub_subscribe_options.hrl0000644000232200023220000000360713610066730022330 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_subscribe_options.xdata %% Form type: http://jabber.org/protocol/pubsub#subscribe_options %% Document: XEP-0060 -type 'show-values'() :: away | chat | dnd | online | xa. -type 'subscription_type'() :: items | nodes. -type 'subscription_depth'() :: 1 | all. -type property() :: {'deliver', boolean()} | {'digest', boolean()} | {'digest_frequency', binary()} | {'expire', binary()} | {'include_body', boolean()} | {'show-values', ['show-values'()]} | {'subscription_type', 'subscription_type'()} | {'subscription_depth', 'subscription_depth'()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'deliver', boolean() | undefined} | {'digest', boolean() | undefined} | {'digest_frequency', binary()} | {'expire', binary()} | {'include_body', boolean() | undefined} | {'show-values', ['show-values'()]} | {'show-values', ['show-values'()], options('show-values'())} | {'subscription_type', 'subscription_type'() | undefined} | {'subscription_type', 'subscription_type'() | undefined, options('subscription_type'())} | {'subscription_depth', 'subscription_depth'() | undefined} | {'subscription_depth', 'subscription_depth'() | undefined, options('subscription_depth'())}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/pubsub_meta_data.hrl0000644000232200023220000000430713610066730020511 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_meta_data.xdata %% Form type: http://jabber.org/protocol/pubsub#meta-data %% Document: XEP-0060 -type 'access_model'() :: authorize | open | presence | roster | whitelist. -type 'publish_model'() :: publishers | subscribers | open. -type property() :: {'contact', [jid:jid()]} | {'creation_date', erlang:timestamp()} | {'creator', jid:jid()} | {'description', binary()} | {'language', binary()} | {'num_subscribers', non_neg_integer()} | {'owner', [jid:jid()]} | {'publisher', [jid:jid()]} | {'title', binary()} | {'type', binary()} | {'max_items', non_neg_integer()} | {'access_model', 'access_model'()} | {'publish_model', 'publish_model'()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'contact', [jid:jid()]} | {'creation_date', erlang:timestamp() | undefined} | {'creator', jid:jid() | undefined} | {'description', binary()} | {'language', binary()} | {'language', binary(), options(binary())} | {'num_subscribers', non_neg_integer() | undefined} | {'owner', [jid:jid()]} | {'publisher', [jid:jid()]} | {'title', binary()} | {'type', binary()} | {'max_items', non_neg_integer() | undefined} | {'access_model', 'access_model'() | undefined} | {'access_model', 'access_model'() | undefined, options('access_model'())} | {'publish_model', 'publish_model'() | undefined} | {'publish_model', 'publish_model'() | undefined, options('publish_model'())}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/flex_offline.hrl0000644000232200023220000000140413610066730017645 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: flex_offline.xdata %% Form type: http://jabber.org/protocol/offline %% Document: XEP-0013 -type property() :: {'number_of_messages', non_neg_integer()}. -type result() :: [property()]. -type form_property() :: {'number_of_messages', non_neg_integer() | undefined}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/xmpp.hrl0000644000232200023220000000245713610066730016202 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% @author Evgeny Khramtsov %%% @doc %%% %%% @end %%% Created : 10 Dec 2015 by Evgeny Khramtsov %%% %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -include("ns.hrl"). -include("jid.hrl"). -include("xmpp_codec.hrl"). -include("fxml.hrl"). -type stanza() :: iq() | presence() | message(). -define(is_stanza(Pkt), (is_record(Pkt, iq) or is_record(Pkt, message) or is_record(Pkt, presence))). -define(stanza_type(Pkt), element(3, Pkt)). -define(stanza_from(Pkt), element(5, Pkt)). -define(stanza_to(Pkt), element(6, Pkt)). xmpp-1.4.4/include/ns.hrl0000644000232200023220000002165413610066730015636 0ustar debalancedebalance%%%---------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -define(NS_COMPONENT, <<"jabber:component:accept">>). -define(NS_SERVER, <<"jabber:server">>). -define(NS_SERVER_DIALBACK, <<"jabber:server:dialback">>). -define(NS_CLIENT, <<"jabber:client">>). -define(NS_DISCO_ITEMS, <<"http://jabber.org/protocol/disco#items">>). -define(NS_DISCO_INFO, <<"http://jabber.org/protocol/disco#info">>). -define(NS_VCARD, <<"vcard-temp">>). -define(NS_VCARD_UPDATE, <<"vcard-temp:x:update">>). -define(NS_AUTH, <<"jabber:iq:auth">>). -define(NS_AUTH_ERROR, <<"jabber:iq:auth:error">>). -define(NS_REGISTER, <<"jabber:iq:register">>). -define(NS_SEARCH, <<"jabber:iq:search">>). -define(NS_ROSTER, <<"jabber:iq:roster">>). -define(NS_ROSTER_VER, <<"urn:xmpp:features:rosterver">>). -define(NS_PRIVACY, <<"jabber:iq:privacy">>). -define(NS_BLOCKING, <<"urn:xmpp:blocking">>). -define(NS_PRIVATE, <<"jabber:iq:private">>). -define(NS_VERSION, <<"jabber:iq:version">>). -define(NS_TIME, <<"urn:xmpp:time">>). -define(NS_LAST, <<"jabber:iq:last">>). -define(NS_XDATA, <<"jabber:x:data">>). -define(NS_IQDATA, <<"jabber:iq:data">>). -define(NS_DELAY, <<"urn:xmpp:delay">>). -define(NS_HINTS, <<"urn:xmpp:hints">>). -define(NS_EXPIRE, <<"jabber:x:expire">>). -define(NS_EVENT, <<"jabber:x:event">>). -define(NS_CHATSTATES, <<"http://jabber.org/protocol/chatstates">>). -define(NS_XCONFERENCE, <<"jabber:x:conference">>). -define(NS_STATS, <<"http://jabber.org/protocol/stats">>). -define(NS_MUC, <<"http://jabber.org/protocol/muc">>). -define(NS_MUC_USER, <<"http://jabber.org/protocol/muc#user">>). -define(NS_MUC_ADMIN, <<"http://jabber.org/protocol/muc#admin">>). -define(NS_MUC_OWNER, <<"http://jabber.org/protocol/muc#owner">>). -define(NS_MUC_UNIQUE, <<"http://jabber.org/protocol/muc#unique">>). -define(NS_PUBSUB, <<"http://jabber.org/protocol/pubsub">>). -define(NS_PUBSUB_EVENT, <<"http://jabber.org/protocol/pubsub#event">>). -define(NS_PUBSUB_META_DATA, <<"http://jabber.org/protocol/pubsub#meta-data">>). -define(NS_PUBSUB_OWNER, <<"http://jabber.org/protocol/pubsub#owner">>). -define(NS_PUBSUB_NMI, <<"http://jabber.org/protocol/pubsub#node-meta-info">>). -define(NS_PUBSUB_ERRORS, <<"http://jabber.org/protocol/pubsub#errors">>). -define(NS_PUBSUB_NODE_CONFIG, <<"http://jabber.org/protocol/pubsub#node_config">>). -define(NS_PUBSUB_SUB_OPTIONS, <<"http://jabber.org/protocol/pubsub#subscribe_options">>). -define(NS_PUBSUB_SUBSCRIBE_OPTIONS, <<"http://jabber.org/protocol/pubsub#subscribe_options">>). -define(NS_PUBSUB_PUBLISH_OPTIONS, <<"http://jabber.org/protocol/pubsub#publish-options">>). -define(NS_PUBSUB_SUB_AUTH, <<"http://jabber.org/protocol/pubsub#subscribe_authorization">>). -define(NS_PUBSUB_GET_PENDING, <<"http://jabber.org/protocol/pubsub#get-pending">>). -define(NS_COMMANDS, <<"http://jabber.org/protocol/commands">>). -define(NS_BYTESTREAMS, <<"http://jabber.org/protocol/bytestreams">>). -define(NS_ADMIN, <<"http://jabber.org/protocol/admin">>). -define(NS_ADMIN_ANNOUNCE, <<"http://jabber.org/protocol/admin#announce">>). -define(NS_ADMIN_ANNOUNCE_ALL, <<"http://jabber.org/protocol/admin#announce-all">>). -define(NS_ADMIN_SET_MOTD, <<"http://jabber.org/protocol/admin#set-motd">>). -define(NS_ADMIN_EDIT_MOTD, <<"http://jabber.org/protocol/admin#edit-motd">>). -define(NS_ADMIN_DELETE_MOTD, <<"http://jabber.org/protocol/admin#delete-motd">>). -define(NS_ADMIN_ANNOUNCE_ALLHOSTS, <<"http://jabber.org/protocol/admin#announce-allhosts">>). -define(NS_ADMIN_ANNOUNCE_ALL_ALLHOSTS, <<"http://jabber.org/protocol/admin#announce-all-allhosts">>). -define(NS_ADMIN_SET_MOTD_ALLHOSTS, <<"http://jabber.org/protocol/admin#set-motd-allhosts">>). -define(NS_ADMIN_EDIT_MOTD_ALLHOSTS, <<"http://jabber.org/protocol/admin#edit-motd-allhosts">>). -define(NS_ADMIN_DELETE_MOTD_ALLHOSTS, <<"http://jabber.org/protocol/admin#delete-motd-allhosts">>). -define(NS_SERVERINFO, <<"http://jabber.org/network/serverinfo">>). -define(NS_RSM, <<"http://jabber.org/protocol/rsm">>). -define(NS_EJABBERD_CONFIG, <<"ejabberd:config">>). -define(NS_STREAM, <<"http://etherx.jabber.org/streams">>). -define(NS_STANZAS, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>). -define(NS_STREAMS, <<"urn:ietf:params:xml:ns:xmpp-streams">>). -define(NS_TLS, <<"urn:ietf:params:xml:ns:xmpp-tls">>). -define(NS_SASL, <<"urn:ietf:params:xml:ns:xmpp-sasl">>). -define(NS_SESSION, <<"urn:ietf:params:xml:ns:xmpp-session">>). -define(NS_BIND, <<"urn:ietf:params:xml:ns:xmpp-bind">>). -define(NS_FEATURE_IQAUTH, <<"http://jabber.org/features/iq-auth">>). -define(NS_FEATURE_IQREGISTER, <<"http://jabber.org/features/iq-register">>). -define(NS_FEATURE_COMPRESS, <<"http://jabber.org/features/compress">>). -define(NS_FEATURE_MSGOFFLINE, <<"msgoffline">>). -define(NS_FEATURE_PRESENCE, <<"presence">>). -define(NS_FEATURE_IQ, <<"iq">>). -define(NS_FLEX_OFFLINE, <<"http://jabber.org/protocol/offline">>). -define(NS_COMPRESS, <<"http://jabber.org/protocol/compress">>). -define(NS_CAPS, <<"http://jabber.org/protocol/caps">>). -define(NS_SHIM, <<"http://jabber.org/protocol/shim">>). -define(NS_ADDRESS, <<"http://jabber.org/protocol/address">>). -define(NS_OOB, <<"jabber:x:oob">>). -define(NS_CAPTCHA, <<"urn:xmpp:captcha">>). -define(NS_MEDIA, <<"urn:xmpp:media-element">>). -define(NS_BOB, <<"urn:xmpp:bob">>). -define(NS_MAM_TMP, <<"urn:xmpp:mam:tmp">>). -define(NS_MAM_0, <<"urn:xmpp:mam:0">>). -define(NS_MAM_1, <<"urn:xmpp:mam:1">>). -define(NS_MAM_2, <<"urn:xmpp:mam:2">>). -define(NS_SID_0, <<"urn:xmpp:sid:0">>). -define(NS_PING, <<"urn:xmpp:ping">>). -define(NS_PUSH_0, <<"urn:xmpp:push:0">>). -define(NS_CARBONS_2, <<"urn:xmpp:carbons:2">>). -define(NS_CARBONS_1, <<"urn:xmpp:carbons:1">>). -define(NS_CARBONS_RULES_0, <<"urn:xmpp:carbons:rules:0">>). -define(NS_FORWARD, <<"urn:xmpp:forward:0">>). -define(NS_CLIENT_STATE, <<"urn:xmpp:csi:0">>). -define(NS_STREAM_MGMT_2, <<"urn:xmpp:sm:2">>). -define(NS_STREAM_MGMT_3, <<"urn:xmpp:sm:3">>). -define(NS_HTTP_UPLOAD, <<"urn:xmpp:http:upload">>). -define(NS_HTTP_UPLOAD_0, <<"urn:xmpp:http:upload:0">>). -define(NS_HTTP_UPLOAD_OLD, <<"eu:siacs:conversations:http:upload">>). -define(NS_THUMBS_1, <<"urn:xmpp:thumbs:1">>). -define(NS_NICK, <<"http://jabber.org/protocol/nick">>). -define(NS_RECEIPTS, <<"urn:xmpp:receipts">>). -define(NS_REPORTING_0, <<"urn:xmpp:reporting:0">>). -define(NS_REPORTING_REASON_ABUSE_0, <<"urn:xmpp:reporting:reason:abuse:0">>). -define(NS_REPORTING_REASON_SPAM_0, <<"urn:xmpp:reporting:reason:spam:0">>). -define(NS_JIDPREP_0, <<"urn:xmpp:jidprep:0">>). -define(NS_SIC_0, <<"urn:xmpp:sic:0">>). -define(NS_SIC_1, <<"urn:xmpp:sic:1">>). -define(NS_MIX_CORE_0, <<"urn:xmpp:mix:core:0">>). -define(NS_MIX_CORE_SEARCHABLE_0, <<"urn:xmpp:mix:core:0#searchable">>). -define(NS_MIX_CORE_CREATE_CHANNEL_0, <<"urn:xmpp:mix:core:0#create-channel">>). -define(NS_MIX_PAM_0, <<"urn:xmpp:mix:pam:0">>). -define(NS_MIX_ROSTER_0, <<"urn:xmpp:mix:roster:0">>). -define(NS_MIX_NODES_MESSAGES, <<"urn:xmpp:mix:nodes:messages">>). -define(NS_MIX_NODES_PRESENCE, <<"urn:xmpp:mix:nodes:presence">>). -define(NS_MIX_NODES_PARTICIPANTS, <<"urn:xmpp:mix:nodes:participants">>). -define(NS_MIX_NODES_CONFIG, <<"urn:xmpp:mix:nodes:config">>). -define(NS_MIX_NODES_INFO, <<"urn:xmpp:mix:nodes:info">>). -define(NS_PRIVILEGE, <<"urn:xmpp:privilege:1">>). -define(NS_DELEGATION, <<"urn:xmpp:delegation:1">>). -define(NS_MUCSUB, <<"urn:xmpp:mucsub:0">>). -define(NS_MUCSUB_NODES_PRESENCE, <<"urn:xmpp:mucsub:nodes:presence">>). -define(NS_MUCSUB_NODES_MESSAGES, <<"urn:xmpp:mucsub:nodes:messages">>). -define(NS_MUCSUB_NODES_PARTICIPANTS, <<"urn:xmpp:mucsub:nodes:participants">>). -define(NS_MUCSUB_NODES_AFFILIATIONS, <<"urn:xmpp:mucsub:nodes:affiliations">>). -define(NS_MUCSUB_NODES_SUBJECT, <<"urn:xmpp:mucsub:nodes:subject">>). -define(NS_MUCSUB_NODES_CONFIG, <<"urn:xmpp:mucsub:nodes:config">>). -define(NS_MUCSUB_NODES_SYSTEM, <<"urn:xmpp:mucsub:nodes:system">>). -define(NS_MUCSUB_NODES_SUBSCRIBERS, <<"urn:xmpp:mucsub:nodes:subscribers">>). -define(NS_AVATAR_DATA, <<"urn:xmpp:avatar:data">>). -define(NS_AVATAR_METADATA, <<"urn:xmpp:avatar:metadata">>). -define(NS_PEP_VCARD_CONVERSION_0, <<"urn:xmpp:pep-vcard-conversion:0">>). -define(NS_BOOKMARKS_CONVERSION_0, <<"urn:xmpp:bookmarks-conversion:0">>). -define(NS_STORAGE_BOOKMARKS, <<"storage:bookmarks">>). -define(NS_X509_0, <<"urn:xmpp:x509:0">>). xmpp-1.4.4/include/muc_roomconfig.hrl0000644000232200023220000001154613610066730020223 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_roomconfig.xdata %% Form type: http://jabber.org/protocol/muc#roomconfig %% Document: XEP-0045 -type 'allowpm'() :: anyone | participants | moderators | none. -type 'allow_private_messages_from_visitors'() :: nobody | moderators | anyone. -type 'maxusers'() :: none | non_neg_integer(). -type 'presencebroadcast'() :: moderator | participant | visitor. -type 'whois'() :: moderators | anyone. -type property() :: {'maxhistoryfetch', binary()} | {'allowpm', 'allowpm'()} | {'allow_private_messages', boolean()} | {'allow_private_messages_from_visitors', 'allow_private_messages_from_visitors'()} | {'allow_visitor_status', boolean()} | {'allow_visitor_nickchange', boolean()} | {'allow_voice_requests', boolean()} | {'allow_subscription', boolean()} | {'voice_request_min_interval', non_neg_integer()} | {'captcha_protected', boolean()} | {'captcha_whitelist', [jid:jid()]} | {'allow_query_users', boolean()} | {'allowinvites', boolean()} | {'changesubject', boolean()} | {'enablelogging', boolean()} | {'getmemberlist', [binary()]} | {'lang', binary()} | {'pubsub', binary()} | {'maxusers', 'maxusers'()} | {'membersonly', boolean()} | {'moderatedroom', boolean()} | {'members_by_default', boolean()} | {'passwordprotectedroom', boolean()} | {'persistentroom', boolean()} | {'presencebroadcast', ['presencebroadcast'()]} | {'publicroom', boolean()} | {'public_list', boolean()} | {'roomadmins', [jid:jid()]} | {'roomdesc', binary()} | {'roomname', binary()} | {'roomowners', [jid:jid()]} | {'roomsecret', binary()} | {'whois', 'whois'()} | {'mam', boolean()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'maxhistoryfetch', binary()} | {'allowpm', 'allowpm'() | undefined} | {'allowpm', 'allowpm'() | undefined, options('allowpm'())} | {'allow_private_messages', boolean() | undefined} | {'allow_private_messages_from_visitors', 'allow_private_messages_from_visitors'() | undefined} | {'allow_private_messages_from_visitors', 'allow_private_messages_from_visitors'() | undefined, options('allow_private_messages_from_visitors'())} | {'allow_visitor_status', boolean() | undefined} | {'allow_visitor_nickchange', boolean() | undefined} | {'allow_voice_requests', boolean() | undefined} | {'allow_subscription', boolean() | undefined} | {'voice_request_min_interval', non_neg_integer() | undefined} | {'captcha_protected', boolean() | undefined} | {'captcha_whitelist', [jid:jid()]} | {'allow_query_users', boolean() | undefined} | {'allowinvites', boolean() | undefined} | {'changesubject', boolean() | undefined} | {'enablelogging', boolean() | undefined} | {'getmemberlist', [binary()]} | {'getmemberlist', [binary()], options(binary())} | {'lang', binary() | undefined} | {'pubsub', binary() | undefined} | {'maxusers', 'maxusers'() | undefined} | {'maxusers', 'maxusers'() | undefined, options('maxusers'())} | {'membersonly', boolean() | undefined} | {'moderatedroom', boolean() | undefined} | {'members_by_default', boolean() | undefined} | {'passwordprotectedroom', boolean() | undefined} | {'persistentroom', boolean() | undefined} | {'presencebroadcast', ['presencebroadcast'()]} | {'presencebroadcast', ['presencebroadcast'()], options('presencebroadcast'())} | {'publicroom', boolean() | undefined} | {'public_list', boolean() | undefined} | {'roomadmins', [jid:jid()]} | {'roomdesc', binary()} | {'roomname', binary()} | {'roomowners', [jid:jid()]} | {'roomsecret', binary()} | {'whois', 'whois'() | undefined} | {'whois', 'whois'() | undefined, options('whois'())} | {'mam', boolean() | undefined}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/push_summary.hrl0000644000232200023220000000211113610066730017735 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: push_summary.xdata %% Form type: urn:xmpp:push:summary %% Document: XEP-0357 -type property() :: {'message-count', non_neg_integer()} | {'pending-subscription-count', non_neg_integer()} | {'last-message-sender', jid:jid()} | {'last-message-body', binary()}. -type result() :: [property()]. -type form_property() :: {'message-count', non_neg_integer() | undefined} | {'pending-subscription-count', non_neg_integer() | undefined} | {'last-message-sender', jid:jid() | undefined} | {'last-message-body', binary()}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/muc_request.hrl0000644000232200023220000000210413610066730017537 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_request.xdata %% Form type: http://jabber.org/protocol/muc#request %% Document: XEP-0045 -type property() :: {'role', participant} | {'jid', jid:jid()} | {'roomnick', binary()} | {'request_allow', boolean()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'role', participant | undefined} | {'role', participant | undefined, options(participant)} | {'jid', jid:jid() | undefined} | {'roomnick', binary()} | {'request_allow', boolean() | undefined}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/mam_query.hrl0000644000232200023220000000172513610066730017212 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: mam_query.xdata %% Form type: urn:xmpp:mam:1 %% Document: XEP-0313 -type property() :: {'with', jid:jid()} | {'start', erlang:timestamp()} | {'end', erlang:timestamp()} | {'withtext', binary()}. -type result() :: [property()]. -type form_property() :: {'with', jid:jid() | undefined} | {'start', erlang:timestamp() | undefined} | {'end', erlang:timestamp() | undefined} | {'withtext', binary()}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/pubsub_get_pending.hrl0000644000232200023220000000147213610066730021055 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_get_pending.xdata %% Form type: http://jabber.org/protocol/pubsub#subscribe_authorization %% Document: XEP-0060 -type property() :: {'node', binary()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'node', binary()} | {'node', binary(), options(binary())}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/xmpp_codec.hrl0000644000232200023220000015676113610066730017347 0ustar debalancedebalance%% Created automatically by XML generator (fxml_gen.erl) %% Source: xmpp_codec.spec -record(text, {lang = <<>> :: binary(), data = <<>> :: binary()}). -type text() :: #text{}. -type iq_type() :: get | set | result | error. -type message_type() :: chat | error | groupchat | headline | normal. -type presence_type() :: available | error | probe | subscribe | subscribed | unavailable | unsubscribe | unsubscribed. -record(iq, {id = <<>> :: binary(), type :: iq_type(), lang = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid(), sub_els = [] :: [xmpp_element() | fxml:xmlel()], meta = #{} :: map()}). -type iq() :: #iq{}. -record(message, {id = <<>> :: binary(), type = normal :: message_type(), lang = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid(), subject = [] :: [#text{}], body = [] :: [#text{}], thread :: undefined | message_thread(), sub_els = [] :: [xmpp_element() | fxml:xmlel()], meta = #{} :: map()}). -type message() :: #message{}. -record(presence, {id = <<>> :: binary(), type = available :: presence_type(), lang = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid(), show :: undefined | 'away' | 'chat' | 'dnd' | 'xa', status = [] :: [#text{}], priority :: undefined | integer(), sub_els = [] :: [xmpp_element() | fxml:xmlel()], meta = #{} :: map()}). -type presence() :: #presence{}. -record(ps_affiliation, {xmlns = <<>> :: binary(), node = <<>> :: binary(), type :: member | none | outcast | owner | publisher | publish_only, jid :: undefined | jid:jid()}). -type ps_affiliation() :: #ps_affiliation{}. -type ps_error_type() :: 'closed-node' | 'configuration-required' | 'invalid-jid' | 'invalid-options' | 'invalid-payload' | 'invalid-subid' | 'item-forbidden' | 'item-required' | 'jid-required' | 'max-items-exceeded' | 'max-nodes-exceeded' | 'nodeid-required' | 'not-in-roster-group' | 'not-subscribed' | 'payload-too-big' | 'payload-required' | 'pending-subscription' | 'precondition-not-met' | 'presence-subscription-required' | 'subid-required' | 'too-many-subscriptions' | 'unsupported' | 'unsupported-access-model'. -type ps_feature() :: 'access-authorize' | 'access-open' | 'access-presence' | 'access-roster' | 'access-whitelist' | 'auto-create' | 'auto-subscribe' | 'collections' | 'config-node' | 'create-and-configure' | 'create-nodes' | 'delete-items' | 'delete-nodes' | 'filtered-notifications' | 'get-pending' | 'instant-nodes' | 'item-ids' | 'last-published' | 'leased-subscription' | 'manage-subscriptions' | 'member-affiliation' | 'meta-data' | 'modify-affiliations' | 'multi-collection' | 'multi-subscribe' | 'outcast-affiliation' | 'persistent-items' | 'presence-notifications' | 'presence-subscribe' | 'publish' | 'publish-options' | 'publish-only-affiliation' | 'publisher-affiliation' | 'purge-nodes' | 'retract-items' | 'retrieve-affiliations' | 'retrieve-default' | 'retrieve-items' | 'retrieve-subscriptions' | 'subscribe' | 'subscription-options' | 'subscription-notifications' | 'multi-items' | undefined. -record(ps_error, {type :: ps_error_type(), feature :: ps_feature()}). -type ps_error() :: #ps_error{}. -record(chatstate, {type :: active | composing | gone | inactive | paused}). -type chatstate() :: #chatstate{}. -record(csi, {type :: active | inactive}). -type csi() :: #csi{}. -record(hint, {type :: 'no-copy' | 'no-store' | 'no-storage' | 'store' | 'no-permanent-store' | 'no-permanent-storage'}). -type hint() :: #hint{}. -record(jingle_error, {reason :: 'out-of-order' | 'tie-break' | 'unknown-session' | 'unsupported-info' | 'security-required'}). -type jingle_error() :: #jingle_error{}. -record(jingle_ft_error, {reason :: 'file-not-available' | 'file-too-large'}). -type jingle_ft_error() :: #jingle_ft_error{}. -type xmpp_host() :: binary() | inet:ip_address() | {binary() | inet:ip_address(), inet:port_number()}. -record(avatar_data, {data = <<>> :: binary()}). -type avatar_data() :: #avatar_data{}. -record(feature_register, {}). -type feature_register() :: #feature_register{}. -record(address, {type :: 'bcc' | 'cc' | 'noreply' | 'ofrom' | 'replyroom' | 'replyto' | 'to', jid :: undefined | jid:jid(), desc = <<>> :: binary(), node = <<>> :: binary(), delivered :: 'false' | 'true' | 'undefined'}). -type address() :: #address{}. -record(sasl_success, {text = <<>> :: binary()}). -type sasl_success() :: #sasl_success{}. -record(adhoc_note, {type = info :: 'error' | 'info' | 'warn', data = <<>> :: binary()}). -type adhoc_note() :: #adhoc_note{}. -record(mam_result, {xmlns = <<>> :: binary(), queryid = <<>> :: binary(), id = <<>> :: binary(), sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type mam_result() :: #mam_result{}. -record(rsm_first, {index :: 'undefined' | non_neg_integer(), data = <<>> :: binary()}). -type rsm_first() :: #rsm_first{}. -record(streamhost, {jid :: jid:jid(), host = <<>> :: binary(), port = 1080 :: non_neg_integer()}). -type streamhost() :: #streamhost{}. -record(x509_challenge_failed, {}). -type x509_challenge_failed() :: #x509_challenge_failed{}. -record(carbons_enable, {}). -type carbons_enable() :: #carbons_enable{}. -record(mix_create, {channel = <<>> :: binary()}). -type mix_create() :: #mix_create{}. -record(carbons_private, {}). -type carbons_private() :: #carbons_private{}. -record(receipt_response, {id = <<>> :: binary()}). -type receipt_response() :: #receipt_response{}. -record(expire, {seconds :: non_neg_integer(), stored :: 'undefined' | non_neg_integer()}). -type expire() :: #expire{}. -record(mix_leave, {}). -type mix_leave() :: #mix_leave{}. -record(muc_unsubscribe, {nick = <<>> :: binary(), jid :: undefined | jid:jid()}). -type muc_unsubscribe() :: #muc_unsubscribe{}. -record(ps_unsubscribe, {node = <<>> :: binary(), jid :: jid:jid(), subid = <<>> :: binary()}). -type ps_unsubscribe() :: #ps_unsubscribe{}. -record(sm_resume, {h :: non_neg_integer(), previd = <<>> :: binary(), xmlns = <<>> :: binary()}). -type sm_resume() :: #sm_resume{}. -record(ping, {}). -type ping() :: #ping{}. -record(delay, {stamp :: erlang:timestamp(), from :: undefined | jid:jid(), desc = <<>> :: binary()}). -type delay() :: #delay{}. -record(muc_history, {maxchars :: 'undefined' | non_neg_integer(), maxstanzas :: 'undefined' | non_neg_integer(), seconds :: 'undefined' | non_neg_integer(), since :: undefined | erlang:timestamp()}). -type muc_history() :: #muc_history{}. -record(thumbnail, {uri = <<>> :: binary(), 'media-type' = <<>> :: binary(), width :: 'undefined' | non_neg_integer(), height :: 'undefined' | non_neg_integer()}). -type thumbnail() :: #thumbnail{}. -record(privilege_perm, {access :: 'message' | 'presence' | 'roster', type :: 'both' | 'get' | 'managed_entity' | 'none' | 'outgoing' | 'roster' | 'set'}). -type privilege_perm() :: #privilege_perm{}. -record(ibb_open, {sid = <<>> :: binary(), 'block-size' :: non_neg_integer(), stanza = iq :: 'iq' | 'message'}). -type ibb_open() :: #ibb_open{}. -record(muc_decline, {reason = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid()}). -type muc_decline() :: #muc_decline{}. -record(upload_slot_0, {get :: binary(), put :: binary(), xmlns = <<>> :: binary()}). -type upload_slot_0() :: #upload_slot_0{}. -record(upload_request_0, {filename = <<>> :: binary(), size :: pos_integer(), 'content-type' = <<>> :: binary(), xmlns = <<>> :: binary()}). -type upload_request_0() :: #upload_request_0{}. -record(ibb_data, {sid = <<>> :: binary(), seq :: non_neg_integer(), data = <<>> :: binary()}). -type ibb_data() :: #ibb_data{}. -record(sm_a, {h :: non_neg_integer(), xmlns = <<>> :: binary()}). -type sm_a() :: #sm_a{}. -record(x509_csr, {name = <<>> :: binary(), der = <<>> :: binary()}). -type x509_csr() :: #x509_csr{}. -record(jingle_ft_received, {creator :: 'initiator' | 'responder' | 'undefined', name = <<>> :: binary()}). -type jingle_ft_received() :: #jingle_ft_received{}. -record(starttls_proceed, {}). -type starttls_proceed() :: #starttls_proceed{}. -record(sm_resumed, {h :: non_neg_integer(), previd = <<>> :: binary(), xmlns = <<>> :: binary()}). -type sm_resumed() :: #sm_resumed{}. -record(x509_request, {transaction = <<>> :: binary(), csr :: #x509_csr{}, cert :: 'undefined' | binary(), signature :: 'undefined' | binary()}). -type x509_request() :: #x509_request{}. -record(stream_start, {from :: undefined | jid:jid(), to :: undefined | jid:jid(), id = <<>> :: binary(), version :: 'undefined' | {non_neg_integer(),non_neg_integer()}, xmlns = <<>> :: binary(), stream_xmlns = <<>> :: binary(), db_xmlns = <<>> :: binary(), lang = <<>> :: binary()}). -type stream_start() :: #stream_start{}. -record(muc_subscribe, {nick = <<>> :: binary(), password = <<>> :: binary(), jid :: undefined | jid:jid(), events = [] :: [binary()]}). -type muc_subscribe() :: #muc_subscribe{}. -record(jingle_ibb_transport, {sid = <<>> :: binary(), 'block-size' :: non_neg_integer(), stanza = iq :: 'iq' | 'message'}). -type jingle_ibb_transport() :: #jingle_ibb_transport{}. -record(stanza_id, {by :: jid:jid(), id = <<>> :: binary()}). -type stanza_id() :: #stanza_id{}. -record(forwarded, {delay :: 'undefined' | #delay{}, sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type forwarded() :: #forwarded{}. -record(privilege, {perms = [] :: [#privilege_perm{}], forwarded :: 'undefined' | #forwarded{}}). -type privilege() :: #privilege{}. -record(message_thread, {parent = <<>> :: binary(), data = <<>> :: binary()}). -type message_thread() :: #message_thread{}. -record(jingle_content, {creator :: 'initiator' | 'responder', disposition = <<>> :: binary(), name = <<>> :: binary(), senders = both :: 'both' | 'initiator' | 'none' | 'responder', sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type jingle_content() :: #jingle_content{}. -record(sasl_challenge, {text = <<>> :: binary()}). -type sasl_challenge() :: #sasl_challenge{}. -record(handshake, {data = <<>> :: binary()}). -type handshake() :: #handshake{}. -record(db_feature, {errors = false :: boolean()}). -type db_feature() :: #db_feature{}. -record(x_conference, {jid :: jid:jid(), password = <<>> :: binary(), reason = <<>> :: binary(), continue :: 'false' | 'true' | 'undefined', thread = <<>> :: binary()}). -type x_conference() :: #x_conference{}. -record(private, {sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type private() :: #private{}. -record(ibb_close, {sid = <<>> :: binary()}). -type ibb_close() :: #ibb_close{}. -record(sm_enable, {max :: 'undefined' | non_neg_integer(), resume = false :: boolean(), xmlns = <<>> :: binary()}). -type sm_enable() :: #sm_enable{}. -record(starttls_failure, {}). -type starttls_failure() :: #starttls_failure{}. -record(gone, {uri = <<>> :: binary()}). -type gone() :: #gone{}. -record(hash, {algo = <<>> :: binary(), data = <<>> :: binary()}). -type hash() :: #hash{}. -record(jingle_ft_range, {offset = 0 :: non_neg_integer(), length :: 'undefined' | non_neg_integer(), hash = [] :: [#hash{}]}). -type jingle_ft_range() :: #jingle_ft_range{}. -record(delegation_query, {to :: jid:jid(), delegate = [] :: [binary()]}). -type delegation_query() :: #delegation_query{}. -record(db_verify, {from = <<>> :: binary(), to = <<>> :: binary(), id = <<>> :: binary(), type :: 'error' | 'invalid' | 'undefined' | 'valid', key = <<>> :: binary(), sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type db_verify() :: #db_verify{}. -record(nick, {name = <<>> :: binary()}). -type nick() :: #nick{}. -record(roster_item, {jid :: jid:jid(), name = <<>> :: binary(), groups = [] :: [binary()], subscription = none :: 'both' | 'from' | 'none' | 'remove' | 'to', ask :: 'subscribe' | 'undefined'}). -type roster_item() :: #roster_item{}. -record(roster_query, {items = [] :: [#roster_item{}], ver :: 'undefined' | binary()}). -type roster_query() :: #roster_query{}. -record(feature_sm, {xmlns = <<>> :: binary()}). -type feature_sm() :: #feature_sm{}. -record(ps_item, {xmlns = <<>> :: binary(), id = <<>> :: binary(), sub_els = [] :: [xmpp_element() | fxml:xmlel()], node = <<>> :: binary(), publisher = <<>> :: binary()}). -type ps_item() :: #ps_item{}. -record(ps_publish, {node = <<>> :: binary(), items = [] :: [#ps_item{}]}). -type ps_publish() :: #ps_publish{}. -record(avatar_pointer, {bytes :: 'undefined' | non_neg_integer(), id = <<>> :: binary(), type = <<>> :: binary(), height :: 'undefined' | non_neg_integer(), width :: 'undefined' | non_neg_integer(), sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type avatar_pointer() :: #avatar_pointer{}. -record(sm_r, {xmlns = <<>> :: binary()}). -type sm_r() :: #sm_r{}. -record(muc_actor, {jid :: undefined | jid:jid(), nick = <<>> :: binary()}). -type muc_actor() :: #muc_actor{}. -record(stat_error, {code :: integer(), reason = <<>> :: binary()}). -type stat_error() :: #stat_error{}. -record(stat, {name = <<>> :: binary(), units = <<>> :: binary(), value = <<>> :: binary(), error :: 'undefined' | #stat_error{}}). -type stat() :: #stat{}. -record(addresses, {list = [] :: [#address{}]}). -type addresses() :: #addresses{}. -record(starttls, {required = false :: boolean()}). -type starttls() :: #starttls{}. -record(last, {seconds :: 'undefined' | non_neg_integer(), status = <<>> :: binary()}). -type last() :: #last{}. -record('see-other-host', {host :: binary() | inet:ip_address() | {binary() | inet:ip_address(),inet:port_number()}}). -type 'see-other-host'() :: #'see-other-host'{}. -record(compress, {methods = [] :: [binary()]}). -type compress() :: #compress{}. -record(redirect, {uri = <<>> :: binary()}). -type redirect() :: #redirect{}. -record(sm_enabled, {id = <<>> :: binary(), location = <<>> :: binary(), max :: 'undefined' | non_neg_integer(), resume = false :: boolean(), xmlns = <<>> :: binary()}). -type sm_enabled() :: #sm_enabled{}. -record(upload_file_too_large, {'max-file-size' :: 'undefined' | integer(), xmlns = <<>> :: binary()}). -type upload_file_too_large() :: #upload_file_too_large{}. -record(legacy_auth, {username :: 'undefined' | binary(), password :: 'undefined' | binary(), digest :: 'undefined' | binary(), resource :: 'undefined' | binary()}). -type legacy_auth() :: #legacy_auth{}. -record(ps_subscribe, {node = <<>> :: binary(), jid :: jid:jid()}). -type ps_subscribe() :: #ps_subscribe{}. -record(idle, {since :: erlang:timestamp()}). -type idle() :: #idle{}. -record(muc_unique, {name = <<>> :: binary()}). -type muc_unique() :: #muc_unique{}. -record(sasl_response, {text = <<>> :: binary()}). -type sasl_response() :: #sasl_response{}. -record(x509_revoke, {cert :: binary(), signature :: binary()}). -type x509_revoke() :: #x509_revoke{}. -record(sasl_auth, {mechanism = <<>> :: binary(), text = <<>> :: binary()}). -type sasl_auth() :: #sasl_auth{}. -record(feature_csi, {}). -type feature_csi() :: #feature_csi{}. -record(upload_retry, {stamp :: undefined | erlang:timestamp()}). -type upload_retry() :: #upload_retry{}. -record(disco_item, {jid :: jid:jid(), name = <<>> :: binary(), node = <<>> :: binary()}). -type disco_item() :: #disco_item{}. -record(report, {reason :: 'abuse' | 'spam' | 'undefined', text = [] :: [#text{}]}). -type report() :: #report{}. -record(block_item, {jid :: jid:jid(), spam_report :: 'undefined' | #report{}}). -type block_item() :: #block_item{}. -record(unblock, {items = [] :: [#block_item{}]}). -type unblock() :: #unblock{}. -record(block, {items = [] :: [#block_item{}]}). -type block() :: #block{}. -record(compression, {methods = [] :: [binary()]}). -type compression() :: #compression{}. -record(muc_subscription, {jid :: undefined | jid:jid(), nick = <<>> :: binary(), events = [] :: [binary()]}). -type muc_subscription() :: #muc_subscription{}. -record(muc_subscriptions, {list = [] :: [#muc_subscription{}]}). -type muc_subscriptions() :: #muc_subscriptions{}. -record(x509_cert_chain, {name = <<>> :: binary(), certs = [] :: [binary()]}). -type x509_cert_chain() :: #x509_cert_chain{}. -record(ps_subscription, {xmlns = <<>> :: binary(), jid :: jid:jid(), type :: 'none' | 'pending' | 'subscribed' | 'unconfigured' | 'undefined', node = <<>> :: binary(), subid = <<>> :: binary(), expiry :: undefined | erlang:timestamp()}). -type ps_subscription() :: #ps_subscription{}. -record(avatar_info, {bytes :: non_neg_integer(), id = <<>> :: binary(), type = <<>> :: binary(), height :: 'undefined' | non_neg_integer(), width :: 'undefined' | non_neg_integer(), url = <<>> :: binary()}). -type avatar_info() :: #avatar_info{}. -record(avatar_meta, {info = [] :: [#avatar_info{}], pointer :: 'undefined' | #avatar_pointer{}}). -type avatar_meta() :: #avatar_meta{}. -record(jidprep, {jid :: jid:jid()}). -type jidprep() :: #jidprep{}. -record(bob_data, {cid = <<>> :: binary(), 'max-age' :: 'undefined' | non_neg_integer(), type = <<>> :: binary(), data = <<>> :: binary()}). -type bob_data() :: #bob_data{}. -record(x509_register, {}). -type x509_register() :: #x509_register{}. -record(muc_item, {actor :: 'undefined' | #muc_actor{}, continue :: 'undefined' | binary(), reason = <<>> :: binary(), affiliation :: 'admin' | 'member' | 'none' | 'outcast' | 'owner' | 'undefined', role :: 'moderator' | 'none' | 'participant' | 'undefined' | 'visitor', jid :: undefined | jid:jid(), nick = <<>> :: binary()}). -type muc_item() :: #muc_item{}. -record(muc_admin, {items = [] :: [#muc_item{}]}). -type muc_admin() :: #muc_admin{}. -record(shim, {headers = [] :: [{binary(),binary()}]}). -type shim() :: #shim{}. -record(caps, {node = <<>> :: binary(), version = <<>> :: binary(), hash = <<>> :: binary(), exts = [] :: [binary()]}). -type caps() :: #caps{}. -record(muc, {history :: 'undefined' | #muc_history{}, password :: 'undefined' | binary()}). -type muc() :: #muc{}. -record(stats, {list = [] :: [#stat{}], node = <<>> :: binary()}). -type stats() :: #stats{}. -record(ps_items, {xmlns = <<>> :: binary(), node = <<>> :: binary(), items = [] :: [#ps_item{}], max_items :: 'undefined' | non_neg_integer(), subid = <<>> :: binary(), retract :: 'undefined' | binary()}). -type ps_items() :: #ps_items{}. -record(mam_prefs, {xmlns = <<>> :: binary(), default :: 'always' | 'never' | 'roster' | 'undefined', always :: undefined | [jid:jid()], never :: undefined | [jid:jid()]}). -type mam_prefs() :: #mam_prefs{}. -record(stream_features, {sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type stream_features() :: #stream_features{}. -record(sic, {ip :: undefined | inet:ip_address(), port :: 'undefined' | non_neg_integer(), xmlns = <<>> :: binary()}). -type sic() :: #sic{}. -record(sasl_abort, {}). -type sasl_abort() :: #sasl_abort{}. -record(receipt_request, {}). -type receipt_request() :: #receipt_request{}. -record(vcard_email, {home = false :: boolean(), work = false :: boolean(), internet = false :: boolean(), pref = false :: boolean(), x400 = false :: boolean(), userid :: 'undefined' | binary()}). -type vcard_email() :: #vcard_email{}. -record(db_result, {from = <<>> :: binary(), to = <<>> :: binary(), type :: 'error' | 'invalid' | 'undefined' | 'valid', key = <<>> :: binary(), sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type db_result() :: #db_result{}. -record(carbons_received, {forwarded :: #forwarded{}}). -type carbons_received() :: #carbons_received{}. -record(ps_retract, {node = <<>> :: binary(), notify = false :: boolean(), items = [] :: [#ps_item{}]}). -type ps_retract() :: #ps_retract{}. -record(upload_slot, {get :: 'undefined' | binary(), put :: 'undefined' | binary(), xmlns = <<>> :: binary()}). -type upload_slot() :: #upload_slot{}. -record(vcard_geo, {lat :: 'undefined' | binary(), lon :: 'undefined' | binary()}). -type vcard_geo() :: #vcard_geo{}. -record(sasl_failure, {reason :: 'aborted' | 'account-disabled' | 'bad-protocol' | 'credentials-expired' | 'encryption-required' | 'incorrect-encoding' | 'invalid-authzid' | 'invalid-mechanism' | 'malformed-request' | 'mechanism-too-weak' | 'not-authorized' | 'temporary-auth-failure' | 'undefined', text = [] :: [#text{}]}). -type sasl_failure() :: #sasl_failure{}. -record(hash_used, {algo = <<>> :: binary()}). -type hash_used() :: #hash_used{}. -record(xevent, {offline = false :: boolean(), delivered = false :: boolean(), displayed = false :: boolean(), composing = false :: boolean(), id :: 'undefined' | binary()}). -type xevent() :: #xevent{}. -record(mix, {submission_id = <<>> :: binary(), jid :: undefined | jid:jid(), nick = <<>> :: binary()}). -type mix() :: #mix{}. -record(carbons_sent, {forwarded :: #forwarded{}}). -type carbons_sent() :: #carbons_sent{}. -record(mam_archived, {by :: jid:jid(), id = <<>> :: binary()}). -type mam_archived() :: #mam_archived{}. -record(compress_failure, {reason :: 'processing-failed' | 'setup-failed' | 'undefined' | 'unsupported-method'}). -type compress_failure() :: #compress_failure{}. -record(origin_id, {id = <<>> :: binary()}). -type origin_id() :: #origin_id{}. -record(x509_ca_list, {certs = [] :: [binary()]}). -type x509_ca_list() :: #x509_ca_list{}. -record(mix_participant, {jid :: jid:jid(), nick = <<>> :: binary()}). -type mix_participant() :: #mix_participant{}. -record(compressed, {}). -type compressed() :: #compressed{}. -record(block_list, {items = [] :: [#block_item{}]}). -type block_list() :: #block_list{}. -record(version, {name :: 'undefined' | binary(), ver :: 'undefined' | binary(), os :: 'undefined' | binary()}). -type version() :: #version{}. -record(jingle_ft_file, {date :: undefined | erlang:timestamp(), desc = [] :: [#text{}], hash = [] :: [#hash{}], 'hash-used' :: 'undefined' | #hash_used{}, 'media-type' :: 'undefined' | binary(), name :: 'undefined' | binary(), size :: 'undefined' | non_neg_integer(), range :: 'undefined' | #jingle_ft_range{}}). -type jingle_ft_file() :: #jingle_ft_file{}. -record(jingle_ft_checksum, {creator :: 'initiator' | 'responder' | 'undefined', name = <<>> :: binary(), file :: #jingle_ft_file{}}). -type jingle_ft_checksum() :: #jingle_ft_checksum{}. -record(jingle_ft_description, {file :: 'undefined' | #jingle_ft_file{}}). -type jingle_ft_description() :: #jingle_ft_description{}. -record(mix_client_leave, {channel :: undefined | jid:jid(), leave :: #mix_leave{}}). -type mix_client_leave() :: #mix_client_leave{}. -record(legacy_auth_feature, {}). -type legacy_auth_feature() :: #legacy_auth_feature{}. -record(bind, {jid :: undefined | jid:jid(), resource = <<>> :: binary()}). -type bind() :: #bind{}. -record(rosterver_feature, {}). -type rosterver_feature() :: #rosterver_feature{}. -record(x509_challenge, {transaction = <<>> :: binary(), uri = <<>> :: binary(), signature :: binary()}). -type x509_challenge() :: #x509_challenge{}. -record(muc_invite, {reason = <<>> :: binary(), from :: undefined | jid:jid(), to :: undefined | jid:jid(), continue :: 'undefined' | binary()}). -type muc_invite() :: #muc_invite{}. -record(vcard_xupdate, {hash :: 'undefined' | binary()}). -type vcard_xupdate() :: #vcard_xupdate{}. -record(bytestreams, {hosts = [] :: [#streamhost{}], used :: undefined | jid:jid(), activate :: undefined | jid:jid(), dstaddr = <<>> :: binary(), mode = tcp :: 'tcp' | 'udp', sid = <<>> :: binary()}). -type bytestreams() :: #bytestreams{}. -record(upload_request, {filename :: binary(), size :: non_neg_integer(), 'content-type' = <<>> :: binary(), xmlns = <<>> :: binary()}). -type upload_request() :: #upload_request{}. -record(xdata_option, {label = <<>> :: binary(), value :: binary()}). -type xdata_option() :: #xdata_option{}. -record(xdata_field, {label = <<>> :: binary(), type :: 'boolean' | 'fixed' | 'hidden' | 'jid-multi' | 'jid-single' | 'list-multi' | 'list-single' | 'text-multi' | 'text-private' | 'text-single' | 'undefined', var = <<>> :: binary(), required = false :: boolean(), desc = <<>> :: binary(), values = [] :: [binary()], options = [] :: [#xdata_option{}], sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type xdata_field() :: #xdata_field{}. -record(push_disable, {jid :: jid:jid(), node = <<>> :: binary()}). -type push_disable() :: #push_disable{}. -record(jingle_s5b_candidate, {cid = <<>> :: binary(), host :: inet:ip_address(), port :: 'undefined' | non_neg_integer(), jid :: jid:jid(), type = direct :: 'assisted' | 'direct' | 'proxy' | 'tunnel', priority :: non_neg_integer()}). -type jingle_s5b_candidate() :: #jingle_s5b_candidate{}. -record(jingle_s5b_transport, {sid = <<>> :: binary(), dstaddr = <<>> :: binary(), mode = tcp :: 'tcp' | 'udp', candidates = [] :: [#jingle_s5b_candidate{}], 'candidate-used' :: 'undefined' | binary(), activated :: 'undefined' | binary(), error :: 'candidate-error' | 'proxy-error' | 'undefined'}). -type jingle_s5b_transport() :: #jingle_s5b_transport{}. -record(delegated, {ns = <<>> :: binary(), attrs = [] :: [binary()]}). -type delegated() :: #delegated{}. -record(carbons_disable, {}). -type carbons_disable() :: #carbons_disable{}. -record(adhoc_actions, {execute :: 'complete' | 'next' | 'prev' | 'undefined', prev = false :: boolean(), next = false :: boolean(), complete = false :: boolean()}). -type adhoc_actions() :: #adhoc_actions{}. -record(vcard_org, {name :: 'undefined' | binary(), units = [] :: [binary()]}). -type vcard_org() :: #vcard_org{}. -record(vcard_tel, {home = false :: boolean(), work = false :: boolean(), voice = false :: boolean(), fax = false :: boolean(), pager = false :: boolean(), msg = false :: boolean(), cell = false :: boolean(), video = false :: boolean(), bbs = false :: boolean(), modem = false :: boolean(), isdn = false :: boolean(), pcs = false :: boolean(), pref = false :: boolean(), number :: 'undefined' | binary()}). -type vcard_tel() :: #vcard_tel{}. -record(rsm_set, {'after' :: 'undefined' | binary(), before :: 'undefined' | binary(), count :: 'undefined' | non_neg_integer(), first :: 'undefined' | #rsm_first{}, index :: 'undefined' | non_neg_integer(), last :: 'undefined' | binary(), max :: 'undefined' | non_neg_integer()}). -type rsm_set() :: #rsm_set{}. -record(mam_fin, {xmlns = <<>> :: binary(), id = <<>> :: binary(), rsm :: 'undefined' | #rsm_set{}, stable :: 'false' | 'true' | 'undefined', complete :: 'false' | 'true' | 'undefined'}). -type mam_fin() :: #mam_fin{}. -record(disco_items, {node = <<>> :: binary(), items = [] :: [#disco_item{}], rsm :: 'undefined' | #rsm_set{}}). -type disco_items() :: #disco_items{}. -record(muc_destroy, {xmlns = <<>> :: binary(), jid :: undefined | jid:jid(), reason = <<>> :: binary(), password :: 'undefined' | binary()}). -type muc_destroy() :: #muc_destroy{}. -record(muc_user, {decline :: 'undefined' | #muc_decline{}, destroy :: 'undefined' | #muc_destroy{}, invites = [] :: [#muc_invite{}], items = [] :: [#muc_item{}], status_codes = [] :: [pos_integer()], password :: 'undefined' | binary()}). -type muc_user() :: #muc_user{}. -record(vcard_name, {family :: 'undefined' | binary(), given :: 'undefined' | binary(), middle :: 'undefined' | binary(), prefix :: 'undefined' | binary(), suffix :: 'undefined' | binary()}). -type vcard_name() :: #vcard_name{}. -record(media_uri, {type = <<>> :: binary(), uri = <<>> :: binary()}). -type media_uri() :: #media_uri{}. -record(media, {height :: 'undefined' | non_neg_integer(), width :: 'undefined' | non_neg_integer(), uri = [] :: [#media_uri{}]}). -type media() :: #media{}. -record(mix_destroy, {channel :: any()}). -type mix_destroy() :: #mix_destroy{}. -record(vcard_key, {type :: 'undefined' | binary(), cred :: 'undefined' | binary()}). -type vcard_key() :: #vcard_key{}. -record(identity, {category = <<>> :: binary(), type = <<>> :: binary(), lang = <<>> :: binary(), name = <<>> :: binary()}). -type identity() :: #identity{}. -record(bookmark_conference, {name = <<>> :: binary(), jid :: jid:jid(), autojoin = false :: boolean(), nick :: 'undefined' | binary(), password :: 'undefined' | binary()}). -type bookmark_conference() :: #bookmark_conference{}. -record(mix_setnick, {nick :: binary()}). -type mix_setnick() :: #mix_setnick{}. -record(xmpp_session, {optional = false :: boolean()}). -type xmpp_session() :: #xmpp_session{}. -record(bookmark_url, {name = <<>> :: binary(), url = <<>> :: binary()}). -type bookmark_url() :: #bookmark_url{}. -record(bookmark_storage, {conference = [] :: [#bookmark_conference{}], url = [] :: [#bookmark_url{}]}). -type bookmark_storage() :: #bookmark_storage{}. -record(oob_x, {url :: binary(), desc = <<>> :: binary(), sid = <<>> :: binary()}). -type oob_x() :: #oob_x{}. -record(vcard_sound, {phonetic :: 'undefined' | binary(), binval :: 'undefined' | binary(), extval :: 'undefined' | binary()}). -type vcard_sound() :: #vcard_sound{}. -record(vcard_photo, {type :: 'undefined' | binary(), binval :: 'undefined' | binary(), extval :: 'undefined' | binary()}). -type vcard_photo() :: #vcard_photo{}. -record(vcard_label, {home = false :: boolean(), work = false :: boolean(), postal = false :: boolean(), parcel = false :: boolean(), dom = false :: boolean(), intl = false :: boolean(), pref = false :: boolean(), line = [] :: [binary()]}). -type vcard_label() :: #vcard_label{}. -record(vcard_adr, {home = false :: boolean(), work = false :: boolean(), postal = false :: boolean(), parcel = false :: boolean(), dom = false :: boolean(), intl = false :: boolean(), pref = false :: boolean(), pobox :: 'undefined' | binary(), extadd :: 'undefined' | binary(), street :: 'undefined' | binary(), locality :: 'undefined' | binary(), region :: 'undefined' | binary(), pcode :: 'undefined' | binary(), ctry :: 'undefined' | binary()}). -type vcard_adr() :: #vcard_adr{}. -record(search_item, {jid :: jid:jid(), first :: 'undefined' | binary(), last :: 'undefined' | binary(), nick :: 'undefined' | binary(), email :: 'undefined' | binary()}). -type search_item() :: #search_item{}. -record(xdata, {type :: 'cancel' | 'form' | 'result' | 'submit', instructions = [] :: [binary()], title :: 'undefined' | binary(), reported :: 'undefined' | [#xdata_field{}], items = [] :: [[#xdata_field{}]], fields = [] :: [#xdata_field{}]}). -type xdata() :: #xdata{}. -record(push_enable, {jid :: jid:jid(), node = <<>> :: binary(), xdata :: 'undefined' | #xdata{}}). -type push_enable() :: #push_enable{}. -record(xcaptcha, {xdata :: #xdata{}}). -type xcaptcha() :: #xcaptcha{}. -record(adhoc_command, {node = <<>> :: binary(), action = execute :: 'cancel' | 'complete' | 'execute' | 'next' | 'prev', sid = <<>> :: binary(), status :: 'canceled' | 'completed' | 'executing' | 'undefined', lang = <<>> :: binary(), actions :: 'undefined' | #adhoc_actions{}, notes = [] :: [#adhoc_note{}], xdata :: 'undefined' | #xdata{}}). -type adhoc_command() :: #adhoc_command{}. -record(search, {instructions :: 'undefined' | binary(), first :: 'undefined' | binary(), last :: 'undefined' | binary(), nick :: 'undefined' | binary(), email :: 'undefined' | binary(), items = [] :: [#search_item{}], xdata :: 'undefined' | #xdata{}}). -type search() :: #search{}. -record(mam_query, {xmlns = <<>> :: binary(), id = <<>> :: binary(), start :: undefined | erlang:timestamp(), 'end' :: undefined | erlang:timestamp(), with :: undefined | jid:jid(), withtext :: 'undefined' | binary(), rsm :: 'undefined' | #rsm_set{}, xdata :: 'undefined' | #xdata{}}). -type mam_query() :: #mam_query{}. -record(pubsub_owner, {affiliations :: 'undefined' | {binary(),[#ps_affiliation{}]}, configure :: 'undefined' | {binary(),'undefined' | #xdata{}}, default :: 'undefined' | {binary(),'undefined' | #xdata{}}, delete :: 'undefined' | {binary(),binary()}, purge :: 'undefined' | binary(), subscriptions :: 'undefined' | {binary(),[#ps_subscription{}]}}). -type pubsub_owner() :: #pubsub_owner{}. -record(ps_options, {node = <<>> :: binary(), jid :: undefined | jid:jid(), subid = <<>> :: binary(), xdata :: 'undefined' | #xdata{}}). -type ps_options() :: #ps_options{}. -record(pubsub, {subscriptions :: 'undefined' | {binary(),[#ps_subscription{}]}, subscription :: 'undefined' | #ps_subscription{}, affiliations :: 'undefined' | {binary(),[#ps_affiliation{}]}, publish :: 'undefined' | #ps_publish{}, publish_options :: 'undefined' | #xdata{}, subscribe :: 'undefined' | #ps_subscribe{}, unsubscribe :: 'undefined' | #ps_unsubscribe{}, options :: 'undefined' | #ps_options{}, items :: 'undefined' | #ps_items{}, retract :: 'undefined' | #ps_retract{}, create :: 'undefined' | binary(), configure :: 'undefined' | {binary(),'undefined' | #xdata{}}, default :: 'undefined' | {binary(),'undefined' | #xdata{}}, delete :: 'undefined' | {binary(),binary()}, purge :: 'undefined' | binary(), rsm :: 'undefined' | #rsm_set{}}). -type pubsub() :: #pubsub{}. -record(ps_event, {items :: 'undefined' | #ps_items{}, purge :: 'undefined' | binary(), subscription :: 'undefined' | #ps_subscription{}, delete :: 'undefined' | {binary(),binary()}, create :: 'undefined' | binary(), configuration :: 'undefined' | {binary(),'undefined' | #xdata{}}}). -type ps_event() :: #ps_event{}. -record(register, {registered = false :: boolean(), remove = false :: boolean(), instructions :: 'undefined' | binary(), username :: 'undefined' | binary(), nick :: 'undefined' | binary(), password :: 'undefined' | binary(), name :: 'undefined' | binary(), first :: 'undefined' | binary(), last :: 'undefined' | binary(), email :: 'undefined' | binary(), address :: 'undefined' | binary(), city :: 'undefined' | binary(), state :: 'undefined' | binary(), zip :: 'undefined' | binary(), phone :: 'undefined' | binary(), url :: 'undefined' | binary(), date :: 'undefined' | binary(), misc :: 'undefined' | binary(), text :: 'undefined' | binary(), key :: 'undefined' | binary(), xdata :: 'undefined' | #xdata{}, sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type register() :: #register{}. -record(disco_info, {node = <<>> :: binary(), identities = [] :: [#identity{}], features = [] :: [binary()], xdata = [] :: [#xdata{}]}). -type disco_info() :: #disco_info{}. -record(sasl_mechanisms, {list = [] :: [binary()]}). -type sasl_mechanisms() :: #sasl_mechanisms{}. -record(offline_item, {node = <<>> :: binary(), action :: 'remove' | 'undefined' | 'view'}). -type offline_item() :: #offline_item{}. -record(offline, {items = [] :: [#offline_item{}], purge = false :: boolean(), fetch = false :: boolean()}). -type offline() :: #offline{}. -record(muc_owner, {destroy :: 'undefined' | #muc_destroy{}, config :: 'undefined' | #xdata{}, items = [] :: [#muc_item{}]}). -type muc_owner() :: #muc_owner{}. -record(delegation, {delegated = [] :: [#delegated{}], forwarded :: 'undefined' | #forwarded{}}). -type delegation() :: #delegation{}. -record(push_notification, {xdata :: 'undefined' | #xdata{}}). -type push_notification() :: #push_notification{}. -record(jingle_reason, {reason :: atom(), text = [] :: [#text{}], sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type jingle_reason() :: #jingle_reason{}. -record(jingle, {action :: atom(), sid = <<>> :: binary(), initiator :: undefined | jid:jid(), responder :: undefined | jid:jid(), content = [] :: [#jingle_content{}], reason :: 'undefined' | #jingle_reason{}, sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type jingle() :: #jingle{}. -record(mix_join, {id = <<>> :: binary(), jid :: undefined | jid:jid(), nick = <<>> :: binary(), subscribe = [] :: [binary()]}). -type mix_join() :: #mix_join{}. -record(mix_client_join, {channel :: undefined | jid:jid(), join :: #mix_join{}}). -type mix_client_join() :: #mix_client_join{}. -record(privacy_item, {order :: non_neg_integer(), action :: 'allow' | 'deny', type :: 'group' | 'jid' | 'subscription' | 'undefined', value = <<>> :: binary(), message = false :: boolean(), iq = false :: boolean(), presence_in = false :: boolean(), presence_out = false :: boolean()}). -type privacy_item() :: #privacy_item{}. -record(privacy_list, {name = <<>> :: binary(), items = [] :: [#privacy_item{}]}). -type privacy_list() :: #privacy_list{}. -record(privacy_query, {lists = [] :: [#privacy_list{}], default :: 'none' | 'undefined' | binary(), active :: 'none' | 'undefined' | binary()}). -type privacy_query() :: #privacy_query{}. -record(sm_failed, {reason :: atom() | #gone{} | #redirect{}, text = [] :: [#text{}], h :: 'undefined' | non_neg_integer(), xmlns = <<>> :: binary()}). -type sm_failed() :: #sm_failed{}. -record(stanza_error, {type :: 'auth' | 'cancel' | 'continue' | 'modify' | 'wait', code :: 'undefined' | non_neg_integer(), by :: undefined | jid:jid(), reason :: atom() | #gone{} | #redirect{}, text = [] :: [#text{}], sub_els = [] :: [xmpp_element() | fxml:xmlel()]}). -type stanza_error() :: #stanza_error{}. -record(stream_error, {reason :: atom() | #'see-other-host'{}, text = [] :: [#text{}]}). -type stream_error() :: #stream_error{}. -record(vcard_logo, {type :: 'undefined' | binary(), binval :: 'undefined' | binary(), extval :: 'undefined' | binary()}). -type vcard_logo() :: #vcard_logo{}. -record(vcard_temp, {version :: 'undefined' | binary(), fn :: 'undefined' | binary(), n :: 'undefined' | #vcard_name{}, nickname :: 'undefined' | binary(), photo :: 'undefined' | #vcard_photo{}, bday :: 'undefined' | binary(), adr = [] :: [#vcard_adr{}], label = [] :: [#vcard_label{}], tel = [] :: [#vcard_tel{}], email = [] :: [#vcard_email{}], jabberid :: 'undefined' | binary(), mailer :: 'undefined' | binary(), tz :: 'undefined' | binary(), geo :: 'undefined' | #vcard_geo{}, title :: 'undefined' | binary(), role :: 'undefined' | binary(), logo :: 'undefined' | #vcard_logo{}, org :: 'undefined' | #vcard_org{}, categories = [] :: [binary()], note :: 'undefined' | binary(), prodid :: 'undefined' | binary(), rev :: 'undefined' | binary(), sort_string :: 'undefined' | binary(), sound :: 'undefined' | #vcard_sound{}, uid :: 'undefined' | binary(), url :: 'undefined' | binary(), class :: 'confidential' | 'private' | 'public' | 'undefined', key :: 'undefined' | #vcard_key{}, desc :: 'undefined' | binary()}). -type vcard_temp() :: #vcard_temp{}. -record(time, {tzo :: 'undefined' | {integer(),integer()}, utc :: undefined | erlang:timestamp()}). -type time() :: #time{}. -type xmpp_element() :: privilege_perm() | ps_options() | carbons_private() | adhoc_actions() | x509_request() | hash() | muc_admin() | text() | mix() | ibb_close() | vcard_photo() | media() | muc_unique() | redirect() | sm_r() | disco_items() | roster_query() | sm_resumed() | db_result() | jidprep() | message_thread() | muc_invite() | hash_used() | stat() | vcard_tel() | stats() | sasl_abort() | jingle_ft_error() | privacy_item() | ping() | sm_failed() | muc_user() | report() | muc_item() | adhoc_note() | mix_participant() | mix_client_join() | vcard_org() | xdata() | upload_retry() | block() | 'see-other-host'() | compress_failure() | sasl_failure() | muc_unsubscribe() | expire() | upload_slot_0() | pubsub_owner() | upload_slot() | mix_join() | push_enable() | feature_register() | bookmark_url() | stanza_id() | register() | db_feature() | starttls() | ps_error() | private() | bookmark_storage() | rsm_first() | jingle_reason() | ps_event() | disco_info() | xevent() | address() | push_disable() | muc_destroy() | receipt_response() | offline() | media_uri() | sasl_mechanisms() | rsm_set() | origin_id() | last() | stream_error() | caps() | xdata_field() | xmpp_session() | stanza_error() | vcard_sound() | starttls_failure() | upload_request_0() | presence() | jingle_error() | x509_challenge_failed() | thumbnail() | jingle_content() | sasl_response() | x509_ca_list() | offline_item() | block_item() | forwarded() | mam_prefs() | vcard_name() | vcard_logo() | avatar_pointer() | compress() | gone() | db_verify() | streamhost() | csi() | mix_create() | sasl_challenge() | mam_fin() | ps_subscription() | mix_leave() | stat_error() | ps_unsubscribe() | starttls_proceed() | muc() | vcard_label() | jingle_ft_checksum() | carbons_sent() | mix_destroy() | receipt_request() | ps_items() | adhoc_command() | bytestreams() | x509_cert_chain() | muc_subscribe() | vcard_email() | privilege() | privacy_query() | bob_data() | legacy_auth() | avatar_info() | message() | carbons_disable() | mam_result() | iq() | mam_archived() | nick() | stream_start() | jingle_ft_file() | sm_enable() | muc_subscription() | x509_csr() | vcard_temp() | vcard_key() | mam_query() | jingle_ft_range() | xcaptcha() | delegation_query() | jingle() | search_item() | disco_item() | compressed() | vcard_geo() | ibb_data() | bind() | bookmark_conference() | rosterver_feature() | delay() | muc_owner() | stream_features() | jingle_ft_received() | x509_register() | compression() | idle() | search() | carbons_enable() | delegation() | muc_subscriptions() | xdata_option() | x509_revoke() | block_list() | roster_item() | handshake() | feature_csi() | legacy_auth_feature() | jingle_ft_description() | delegated() | mix_client_leave() | muc_decline() | sm_resume() | vcard_adr() | mix_setnick() | jingle_s5b_candidate() | unblock() | upload_file_too_large() | sm_a() | time() | ps_subscribe() | avatar_meta() | x509_challenge() | shim() | hint() | jingle_s5b_transport() | vcard_xupdate() | ps_retract() | version() | ps_item() | ps_publish() | jingle_ibb_transport() | identity() | sasl_auth() | push_notification() | x_conference() | sasl_success() | privacy_list() | upload_request() | carbons_received() | sic() | sm_enabled() | chatstate() | oob_x() | addresses() | feature_sm() | ibb_open() | avatar_data() | ps_affiliation() | muc_history() | muc_actor() | pubsub(). xmpp-1.4.4/include/http_upload.hrl0000644000232200023220000000144713610066730017537 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: http_upload.xdata %% Form type: urn:xmpp:http:upload:0, urn:xmpp:http:upload, eu:siacs:conversations:http:upload %% Document: XEP-0363 -type property() :: {'max-file-size', non_neg_integer()}. -type result() :: [property()]. -type form_property() :: {'max-file-size', non_neg_integer() | undefined}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/muc_roominfo.hrl0000644000232200023220000000401313610066730017700 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: muc_roominfo.xdata %% Form type: http://jabber.org/protocol/muc#roominfo %% Document: XEP-0045 -type 'allowpm'() :: anyone | participants | moderators | none. -type property() :: {'maxhistoryfetch', non_neg_integer()} | {'allowinvites', boolean()} | {'allowpm', 'allowpm'()} | {'contactjid', [jid:jid()]} | {'description', binary()} | {'lang', binary()} | {'ldapgroup', binary()} | {'logs', binary()} | {'roomname', binary()} | {'occupants', non_neg_integer()} | {'subject', binary()} | {'subjectmod', boolean()} | {'pubsub', binary()} | {'changesubject', boolean()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'maxhistoryfetch', non_neg_integer() | undefined} | {'allowinvites', boolean() | undefined} | {'allowpm', 'allowpm'() | undefined} | {'allowpm', 'allowpm'() | undefined, options('allowpm'())} | {'contactjid', [jid:jid()]} | {'description', binary()} | {'lang', binary() | undefined} | {'ldapgroup', binary()} | {'logs', binary()} | {'roomname', binary()} | {'occupants', non_neg_integer() | undefined} | {'subject', binary()} | {'subjectmod', boolean() | undefined} | {'pubsub', binary() | undefined} | {'changesubject', boolean() | undefined}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/captcha_form.hrl0000644000232200023220000000360613610066730017641 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: captcha_form.xdata %% Form type: urn:xmpp:captcha %% Document: XEP-0158 -type property() :: {'answers', non_neg_integer()} | {'audio_recog', binary()} | {'challenge', binary()} | {'from', jid:jid()} | {'ocr', binary()} | {'picture_q', binary()} | {'picture_recog', binary()} | {'qa', binary()} | {'SHA-256', binary()} | {'sid', binary()} | {'speech_q', binary()} | {'speech_recog', binary()} | {'video_q', binary()} | {'video_recog', binary()} | {'captcha-fallback-text', binary()} | {'captcha-fallback-url', binary()}. -type result() :: [property()]. -type form_property() :: {'answers', non_neg_integer() | undefined} | {'audio_recog', binary()} | {'challenge', binary()} | {'from', jid:jid() | undefined} | {'ocr', binary()} | {'picture_q', binary()} | {'picture_recog', binary()} | {'qa', binary()} | {'SHA-256', binary()} | {'sid', binary()} | {'speech_q', binary()} | {'speech_recog', binary()} | {'video_q', binary()} | {'video_recog', binary()} | {'captcha-fallback-text', binary()} | {'captcha-fallback-url', binary()}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/include/scram.hrl0000644000232200023220000000176713610066730016326 0ustar debalancedebalance%%%------------------------------------------------------------------- %%% %%% Copyright (C) 2002-2019 ProcessOne, SARL. All Rights Reserved. %%% %%% Licensed under the Apache License, Version 2.0 (the "License"); %%% you may not use this file except in compliance with the License. %%% You may obtain a copy of the License at %%% %%% http://www.apache.org/licenses/LICENSE-2.0 %%% %%% Unless required by applicable law or agreed to in writing, software %%% distributed under the License is distributed on an "AS IS" BASIS, %%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %%% See the License for the specific language governing permissions and %%% limitations under the License. %%% %%%------------------------------------------------------------------- -record(scram, {storedkey = <<"">> :: binary(), serverkey = <<"">> :: binary(), salt = <<"">> :: binary(), iterationcount = 0 :: integer()}). -type scram() :: #scram{}. -define(SCRAM_DEFAULT_ITERATION_COUNT, 4096). xmpp-1.4.4/include/pubsub_publish_options.hrl0000644000232200023220000000206613610066730022013 0ustar debalancedebalance%% Created automatically by xdata generator (xdata_codec.erl) %% Source: pubsub_publish_options.xdata %% Form type: http://jabber.org/protocol/pubsub#publish-options %% Document: XEP-0060 -type 'access_model'() :: authorize | open | presence | roster | whitelist. -type property() :: {'persist_items', boolean()} | {'access_model', 'access_model'()}. -type result() :: [property()]. -type options(T) :: [{binary(), T}]. -type form_property() :: {'persist_items', boolean() | undefined} | {'access_model', 'access_model'() | undefined} | {'access_model', 'access_model'() | undefined, options('access_model'())}. -type form() :: [form_property() | xdata_field()]. -type error_reason() :: {form_type_mismatch, binary()} | {bad_var_value, binary(), binary()} | {missing_required_var, binary(), binary()} | {missing_value, binary(), binary()} | {too_many_values, binary(), binary()} | {unknown_var, binary(), binary()}. xmpp-1.4.4/doc/0000755000232200023220000000000013610066730013621 5ustar debalancedebalancexmpp-1.4.4/doc/API.md0000644000232200023220000022574613610066730014574 0ustar debalancedebalanceErlang/Elixir XMPP library API documentation ============================================ The document describes exported functions from the following modules: 1. [xmpp](#xmpp) 2. [xmpp_util](#xmpp_util) 3. [jid](#jid) # xmpp The following functions are exported from `xmpp` module: - [decode/1](#decode1) - [decode/3](#decode3) - [encode/1](#encode1) - [encode/2](#encode2) - [get_id/1](#get_id1) - [set_id/2](#set_id2) - [get_type/1](#get_type1) - [set_type/2](#set_type2) - [get_lang/1](#get_lang1) - [set_lang/2](#set_lang2) - [get_from/1](#get_from1) - [set_from/2](#set_from2) - [get_to/1](#get_to1) - [set_to/2](#set_to2) - [set_from_to/3](#set_from_to3) - [get_els/1](#get_els1) - [set_els/2](#set_els2) - [get_subtag/2](#get_subtag2) - [get_subtags/2](#get_subtags2) - [try_subtag/2](#try_subtag2) - [try_subtags/2](#try_subtags2) - [set_subtag/2](#set_subtag2) - [remove_subtag/2](#remove_subtag2) - [has_subtag/2](#has_subtag2) - [append_subtags/2](#append_subtags2) - [get_meta/1](#get_meta1) - [get_meta/2](#get_meta2) - [get_meta/3](#get_meta3) - [set_meta/2](#set_meta2) - [put_meta/3](#put_meta3) - [update_meta/3](#update_meta3) - [del_meta/2](#del_meta2) - [is_stanza/1](#is_stanza1) - [is_known_tag/1](#is_known_tag1) - [is_known_tag/2](#is_known_tag2) - [get_ns/1](#get_ns1) - [get_name/1](#get_name1) - [make_iq_result/1](#make_iq_result1) - [make_iq_result/2](#make_iq_result2) - [make_error/2](#make_error2) - [get_error/1](#get_error1) - [format_error/1](#format_error1) - [io_format_error/1](#io_format_error1) - [format_stanza_error/1](#format_stanza_error1) - [format_stanza_error/2](#format_stanza_error2) - [format_stream_error/1](#format_stream_error1) - [format_stream_error/2](#format_stream_error2) - [format_sasl_error/1](#format_sasl_error1) - [format_sasl_error/2](#format_sasl_error2) - [pp/1](#pp1) - [set_tr_callback/1](#set_tr_callback1) - [get_text/1](#get_text1) - [get_text/2](#get_text2) - [mk_text/1](#mk_text1) - [mk_text/2](#mk_text2) - [err_bad_request/0](#err_bad_request0) - [err_bad_request/2](#err_bad_request2) - [err_conflict/0](#err_conflict0) - [err_conflict/2](#err_conflict2) - [err_feature_not_implemented/0](#err_feature_not_implemented0) - [err_feature_not_implemented/2](#err_feature_not_implemented2) - [err_forbidden/0](#err_forbidden0) - [err_forbidden/2](#err_forbidden2) - [err_gone/1](#err_gone1) - [err_gone/3](#err_gone3) - [err_internal_server_error/0](#err_internal_server_error0) - [err_internal_server_error/2](#err_internal_server_error2) - [err_item_not_found/0](#err_item_not_found0) - [err_item_not_found/2](#err_item_not_found2) - [err_jid_malformed/0](#err_jid_malformed0) - [err_jid_malformed/2](#err_jid_malformed2) - [err_not_acceptable/0](#err_not_acceptable0) - [err_not_acceptable/2](#err_not_acceptable2) - [err_not_allowed/0](#err_not_allowed0) - [err_not_allowed/2](#err_not_allowed2) - [err_not_authorized/0](#err_not_authorized0) - [err_not_authorized/2](#err_not_authorized2) - [err_payment_required/0](#err_payment_required0) - [err_payment_required/2](#err_payment_required2) - [err_policy_violation/0](#err_policy_violation0) - [err_policy_violation/2](#err_policy_violation2) - [err_recipient_unavailable/0](#err_recipient_unavailable0) - [err_recipient_unavailable/2](#err_recipient_unavailable2) - [err_redirect/1](#err_redirect1) - [err_redirect/3](#err_redirect3) - [err_registration_required/0](#err_registration_required0) - [err_registration_required/2](#err_registration_required2) - [err_remote_server_not_found/0](#err_remote_server_not_found0) - [err_remote_server_not_found/2](#err_remote_server_not_found2) - [err_remote_server_timeout/0](#err_remote_server_timeout0) - [err_remote_server_timeout/2](#err_remote_server_timeout2) - [err_resource_constraint/0](#err_resource_constraint0) - [err_resource_constraint/2](#err_resource_constraint2) - [err_service_unavailable/0](#err_service_unavailable0) - [err_service_unavailable/2](#err_service_unavailable2) - [err_subscription_required/0](#err_subscription_required0) - [err_subscription_required/2](#err_subscription_required2) - [err_undefined_condition/1](#err_undefined_condition1) - [err_undefined_condition/3](#err_undefined_condition3) - [err_unexpected_request/0](#err_unexpected_request0) - [err_unexpected_request/2](#err_unexpected_request2) - [serr_bad_format/0](#serr_bad_format0) - [serr_bad_format/2](#serr_bad_format2) - [serr_bad_namespace_prefix/0](#serr_bad_namespace_prefix0) - [serr_bad_namespace_prefix/2](#serr_bad_namespace_prefix2) - [serr_conflict/0](#serr_conflict0) - [serr_conflict/2](#serr_conflict2) - [serr_connection_timeout/0](#serr_connection_timeout0) - [serr_connection_timeout/2](#serr_connection_timeout2) - [serr_host_gone/0](#serr_host_gone0) - [serr_host_gone/2](#serr_host_gone2) - [serr_host_unknown/0](#serr_host_unknown0) - [serr_host_unknown/2](#serr_host_unknown2) - [serr_improper_addressing/0](#serr_improper_addressing0) - [serr_improper_addressing/2](#serr_improper_addressing2) - [serr_internal_server_error/0](#serr_internal_server_error0) - [serr_internal_server_error/2](#serr_internal_server_error2) - [serr_invalid_from/0](#serr_invalid_from0) - [serr_invalid_from/2](#serr_invalid_from2) - [serr_invalid_id/0](#serr_invalid_id0) - [serr_invalid_id/2](#serr_invalid_id2) - [serr_invalid_namespace/0](#serr_invalid_namespace0) - [serr_invalid_namespace/2](#serr_invalid_namespace2) - [serr_invalid_xml/0](#serr_invalid_xml0) - [serr_invalid_xml/2](#serr_invalid_xml2) - [serr_not_authorized/0](#serr_not_authorized0) - [serr_not_authorized/2](#serr_not_authorized2) - [serr_not_well_formed/0](#serr_not_well_formed0) - [serr_not_well_formed/2](#serr_not_well_formed2) - [serr_policy_violation/0](#serr_policy_violation0) - [serr_policy_violation/2](#serr_policy_violation2) - [serr_remote_connection_failed/0](#serr_remote_connection_failed0) - [serr_remote_connection_failed/2](#serr_remote_connection_failed2) - [serr_reset/0](#serr_reset0) - [serr_reset/2](#serr_reset2) - [serr_resource_constraint/0](#serr_resource_constraint0) - [serr_resource_constraint/2](#serr_resource_constraint2) - [serr_restricted_xml/0](#serr_restricted_xml0) - [serr_restricted_xml/2](#serr_restricted_xml2) - [serr_see_other_host/1](#serr_see_other_host1) - [serr_see_other_host/3](#serr_see_other_host3) - [serr_system_shutdown/0](#serr_system_shutdown0) - [serr_system_shutdown/2](#serr_system_shutdown2) - [serr_undefined_condition/0](#serr_undefined_condition0) - [serr_undefined_condition/2](#serr_undefined_condition2) - [serr_unsupported_encoding/0](#serr_unsupported_encoding0) - [serr_unsupported_encoding/2](#serr_unsupported_encoding2) - [serr_unsupported_feature/0](#serr_unsupported_feature0) - [serr_unsupported_feature/2](#serr_unsupported_feature2) - [serr_unsupported_stanza_type/0](#serr_unsupported_stanza_type0) - [serr_unsupported_stanza_type/2](#serr_unsupported_stanza_type2) - [serr_unsupported_version/0](#serr_unsupported_version0) - [serr_unsupported_version/2](#serr_unsupported_version2) ## decode/1 ```erlang -spec decode(El :: xmlel() | xmpp_element()) -> xmpp_element(). ``` Shorthand for `decode(El, ?NS_CLIENT, [])`. ## decode/3 ```erlang -spec decode(El :: xmlel() | xmpp_element(), Namespace :: binary(), [Option]) -> Pkt :: xmpp_element(). ``` Decodes `xmlel()` element into `xmpp_element()`. The only available value of `Option` is `ignore_els`: if this option is set, lazy decoding is performed. By default, full decoding is applied, i.e. all known sub-elements get decoded. If `El` doesn't possess an `xmlns` attribute, it is assumed that it is within namespace `Namespace`. The function might **fail** with `{xmpp_codec, Reason}` exception. The value of `Reason` can be used to format the failure reason into human readable description using [format_error/1](#format_error1) or [io_format_error/1](#io_format_error1) functions. In the examples below we assume `El` is obtained from the following XML: ```xml ``` thus it is defined as: ```erlang #xmlel{name = <<"message">>,attrs = [], children = [#xmlel{name = <<"composing">>, attrs = [{<<"xmlns">>, <<"http://jabber.org/protocol/chatstates">>}], children = []}, #xmlel{name = <<"foo">>, attrs = [{<<"xmlns">>,<<"unknown:namespace">>}], children = []}]} ``` **Example 1**: lazy decoding ```erlang > xmpp:decode(El, <<"jabber:client">>, [ignore_els]). #message{id = <<>>,type = normal,lang = <<>>, from = undefined,to = undefined,subject = [],body = [], thread = undefined, sub_els = [#xmlel{name = <<"composing">>, attrs = [{<<"xmlns">>, <<"http://jabber.org/protocol/chatstates">>}], children = []}, #xmlel{name = <<"foo">>, attrs = [{<<"xmlns">>,<<"unknown:namespace">>}], children = []}], meta = #{}} ``` Note that sub-elements (a list in `#message.sub_els` field) remain untouched: during lazy decoding only top-level element is decoded. **Example 2**: full decoding ```erlang > xmpp:decode(El, <<"jabber:client">>, []). #message{id = <<>>,type = normal,lang = <<>>, from = undefined,to = undefined,subject = [],body = [], thread = undefined, sub_els = [#chatstate{type = composing}, #xmlel{name = <<"foo">>, attrs = [{<<"xmlns">>,<<"unknown:namespace">>}], children = []}], meta = #{}} ``` Note that in this case all known sub-elements were decoded, and unknown sub-elements (`` in our case) remain untouched. **Example 3**: no namespace is provided and `El` doesn't possess any ```erlang > xmpp:decode(El, <<>>, []). ** exception error: {xmpp_codec,{missing_tag_xmlns,<<"message">>}} in function xmpp_codec:decode/3 (src/xmpp_codec.erl, line 16) ``` It is safe to apply the function to `xmpp_element()`: **Example 4**: double decoding ```erlang > xmpp:decode(xmpp:decode(El, <<"jabber:client">>, [])). #message{id = <<>>,type = normal,lang = <<>>, from = undefined,to = undefined,subject = [],body = [], thread = undefined, sub_els = [#chatstate{type = composing}, #xmlel{name = <<"foo">>, attrs = [{<<"xmlns">>,<<"unknown:namespace">>}], children = []}], meta = #{}} ``` ## encode/1 ```erlang -spec encode(Pkt :: xmpp_element() | xmlel()) -> El :: xmlel(). ``` Shorthand for `encode(Pkt, <<>>)`. ## encode/2 ```erlang -spec encode(Pkt :: xmpp_element() | xmlel(), Namespace :: binary()) -> El :: xmlel(). ``` Encodes `xmpp_element()` into `xmlel()`. `Namespace` is a top-level namespace: it is used to tell the codec whether to include `xmlns` attribute into resulting `xmlel()` element or not - if the `Pkt` is within the same `Namespace`, `xmlns` attribute will be omitted in the result. **Example 1**: encoding without top-level namespace ```erlang > xmpp:encode(#message{}, <<>>). #xmlel{name = <<"message">>, attrs = [{<<"xmlns">>,<<"jabber:client">>}], children = []} ``` **Example 2**: encoding within 'jabber:client' namespace ```erlang > xmpp:encode(#message{}, <<"jabber:client">>). #xmlel{name = <<"message">>,attrs = [],children = []} ``` Note that `xmlns` attribute is omitted in this case because `message()` stanza is defined within 'jabber:client' namespace. **Example 3**: encoding within 'urn:xmpp:time' namespace ```erlang > xmpp:encode(#message{}, <<"urn:xmpp:time">>). #xmlel{name = <<"message">>, attrs = [{<<"xmlns">>,<<"jabber:client">>}], children = []} ``` Note that `xmlns` is included in the result because `message()` stanza is not defined within 'urn:xmpp:time' namespace. **Example 4**: encoding with sub-elements ```erlang > xmpp:encode(#message{sub_els = [#chatstate{type = composing}]}). #xmlel{name = <<"message">>, attrs = [{<<"xmlns">>,<<"jabber:client">>}], children = [#xmlel{name = <<"composing">>, attrs = [{<<"xmlns">>, <<"http://jabber.org/protocol/chatstates">>}], children = []}]} ``` It's acceptable to encode XMPP elements whose sub-elements are of mixed content, i.e. `sub_els` field contains both `xmpp_element()` and `xmlel()` elements as shown in the following example. **Example 5**: encoding with mixed sub-elements ```erlang > xmpp:encode(#message{sub_els = [#chatstate{type = composing}, #xmlel{name = <<"foo">>, attrs = [{<<"xmlns">>, <<"unknown:namespace">>}]}]}). #xmlel{name = <<"message">>, attrs = [{<<"xmlns">>,<<"jabber:client">>}], children = [#xmlel{name = <<"composing">>, attrs = [{<<"xmlns">>, <<"http://jabber.org/protocol/chatstates">>}], children = []}, #xmlel{name = <<"foo">>, attrs = [{<<"xmlns">>,<<"unknown:namespace">>}], children = []}]} ``` It is safe to apply the function to `xmlel()` elements **Example 6**: double encoding ```erlang > xmpp:encode(xmpp:encode(#message{})). #xmlel{name = <<"message">>, attrs = [{<<"xmlns">>,<<"jabber:client">>}], children = []} ``` > **NOTE**: encoding would never fail as long as the > provided input is a valid `xmpp_element()` with valid values of its record > fields. Use [Dialyzer](http://erlang.org/doc/man/dialyzer.html) to validate this. ## get_id/1 ```erlang -spec get_id(stanza() | xmlel()) -> binary(). ``` Returns a value of `id` field of a `stanza()` or a value of `id` attribute of an `xmlel()` element. **Example 1**: obtaining `id` of `message()` ```erlang > xmpp:get_id(#message{id = <<"abcd">>}). <<"abcd">> ``` **Example 2**: obtaining `id` of `xmlel()` ```erlang > xmpp:get_id(#xmlel{attrs = [{<<"id">>, <<"abcd">>}]}). <<"abcd">> ``` ## set_id/2 ```erlang -spec set_id(iq(), binary()) -> iq(); (message(), binary()) -> message(); (presence(), binary()) -> presence(). ``` Sets `id` field of a `stanza()`. **Example 1**: setting `id` field of `iq()` ```erlang xmpp:set_id(#iq{}, <<"abcd">>). > #iq{id = <<"abcd">>,type = undefined,lang = <<>>, from = undefined,to = undefined,sub_els = [],meta = #{}} ``` ## get_type/1 ```erlang -spec get_type(iq()) -> iq_type(); (message()) -> message_type(); (presence()) -> presence_type(); (xmlel()) -> binary(). ``` Returns a value of `type` field of a `stanza()` or a value of `type` attribute of an `xmlel()` element. **Example 1**: obtaining `type` of `presence()` ```erlang > xmpp:get_type(#presence{}). available ``` **Example 2**: obtaining `type` of `xmlel()` ```erlang > xmpp:get_type(#xmlel{attrs = [{<<"type">>, <<"set">>}]}). <<"set">> ``` ## set_type/2 ```erlang -spec set_type(iq(), iq_type()) -> iq(); (message(), message_type()) -> message(); (presence(), presence_type()) -> presence(). ``` Sets `type` field of a `stanza()`. **Example 1**: setting `type` field of `message()` ```erlang > xmpp:set_type(#message{}, chat). #message{id = <<>>,type = chat,lang = <<>>,from = undefined, to = undefined,subject = [],body = [],thread = undefined, sub_els = [],meta = #{}} ``` ## get_lang/1 ```erlang -spec get_lang(stanza() | xmlel()) -> binary(). ``` Returns a value of `lang` field of a `stanza()` or a value of `xml:lang` attribute of an `xmlel()` element. **Example 1**: obtaining `lang` of `iq()` ```erlang > xmpp:get_lang(#iq{lang = <<"fr">>}). <<"fr">> ``` **Example 2**: obtaining `xml:lang` of `xmlel()` ```erlang > xmpp:get_lang(#xmlel{attrs = [{<<"xml:lang">>, <<"fr">>}]}). <<"fr">> ``` ## set_lang/2 ```erlang -spec set_lang(iq(), binary()) -> iq(); (message(), binary()) -> message(); (presence(), binary()) -> presence(). ``` Sets `lang` field of a `stanza()`. **Example 1**: setting `lang` field of `presence()` ```erlang > xmpp:set_lang(#presence{}, <<"fr">>). #presence{id = <<>>,type = available,lang = <<"fr">>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [],meta = #{}} ``` ## get_from/1 ```erlang -spec get_from(stanza()) -> undefined | jid(). ``` Returns a value of `from` field of a `stanza()`. **Example 1**: obtaining `from` of `message()` ```erlang > xmpp:get_from(#message{from = jid:decode(<<"user@server/resource">>)}). #jid{user = <<"user">>,server = <<"server">>, resource = <<"resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"resource">>} ``` **Example 2**: `from` field is not set ```erlang > xmpp:get_from(#message{}). undefined ``` ## set_from/2 ```erlang -spec set_from(iq(), jid:jid() | undefined) -> iq(); (message(), jid:jid() | undefined) -> message(); (presence(), jid:jid() | undefined) -> presence(). ``` Sets `from` field of a `stanza()`. **Example 1**: setting `from` field of `presence()` ```erlang > xmpp:set_from(#presence{}, jid:decode(<<"user@server/resource">>)). #presence{id = <<>>,type = available,lang = <<>>, from = #jid{user = <<"user">>,server = <<"server">>, resource = <<"resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"resource">>}, to = undefined,show = undefined,status = [], priority = undefined,sub_els = [],meta = #{}} ``` **Example 2**: removing `from` value from `iq()` ```erlang > xmpp:set_from(#iq{from = jid:decode(<<"user@server/resource">>)}, undefined). #iq{id = <<>>,type = undefined,lang = <<>>,from = undefined, to = undefined,sub_els = [],meta = #{}} ``` ## get_to/1 ```erlang -spec get_to(stanza()) -> undefined | jid(). ``` Returns a value of `to` field of a `stanza()`. **Example 1**: obtaining `to` of `message()` ```erlang > xmpp:get_to(#message{to = jid:decode(<<"user@server/resource">>)}). #jid{user = <<"user">>,server = <<"server">>, resource = <<"resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"resource">>} ``` **Example 2**: `to` field is not set ```erlang > xmpp:get_to(#message{}). undefined ``` ## set_to/2 ```erlang -spec set_to(iq(), jid:jid() | undefined) -> iq(); (message(), jid:jid() | undefined) -> message(); (presence(), jid:jid() | undefined) -> presence(). ``` Sets `to` field of a `stanza()`. **Example 1**: setting `to` field of `presence()` ```erlang > xmpp:set_to(#presence{}, jid:decode(<<"user@server/resource">>)). #presence{id = <<>>,type = available,lang = <<>>, from = undefined, to = #jid{user = <<"user">>,server = <<"server">>, resource = <<"resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"resource">>}, show = undefined,status = [],priority = undefined, sub_els = [],meta = #{}} ``` **Example 2**: removing `to` value from `iq()` ```erlang > xmpp:set_to(#iq{to = jid:decode(<<"user@server/resource">>)}, undefined). #iq{id = <<>>,type = undefined,lang = <<>>,from = undefined, to = undefined,sub_els = [],meta = #{}} ``` ## set_from_to/3 ```erlang -spec set_from_to(iq(), undefined | jid:jid(), undefined | jid:jid()) -> iq(); (message(), undefined | jid:jid(), undefined | jid:jid()) -> message(); (presence(), undefined | jid:jid(), undefined | jid:jid()) -> presence(). ``` Sets `from` and `to` fields of a `stanza()`. **Example 1**: setting `from` and `to` fields of `message()` ```erlang > xmpp:set_from_to(#message{}, jid:decode(<<"user1@server.com">>), jid:decode(<<"user2@server.com">>)). #message{id = <<>>,type = normal,lang = <<>>, from = #jid{user = <<"user1">>,server = <<"server.com">>, resource = <<>>,luser = <<"user1">>, lserver = <<"server.com">>,lresource = <<>>}, to = #jid{user = <<"user2">>,server = <<"server.com">>, resource = <<>>,luser = <<"user2">>, lserver = <<"server.com">>,lresource = <<>>}, subject = [],body = [],thread = undefined,sub_els = [], meta = #{}} ``` ## get_els/1 ```erlang -spec get_els(stanza()) -> [xmpp_element() | xmlel()]; (xmlel()) -> [xmlel()]. ``` Returns a value of `sub_els` field of a `stanza()` or child elements of an `xmlel()` element. **Example 1**: obtaining `sub_els` of `message()` ```erlang > xmpp:get_els(#message{sub_els = [#chatstate{type = composing}, #xmlel{name = <<"foo">>}]}). [#chatstate{type = composing}, #xmlel{name = <<"foo">>,attrs = [],children = []}] ``` **Example 2**: obtaining child elements of `xmlel()` ```erlang > xmpp:get_els(#xmlel{children = [#xmlel{name = <<"foo">>}, {xmlcdata, <<"bar">>}]}). [#xmlel{name = <<"foo">>,attrs = [],children = []}] ``` Note that only `xmlel()` elements are returned and `xmlcdata()` is ignored. ## set_els/2 ```erlang -spec set_els(Stanza :: iq(), [xmpp_element() | xmlel()]) -> iq(); (Stanza :: message(), [xmpp_element() | xmlel()]) -> message(); (Stanza :: presence(), [xmpp_element() | xmlel()]) -> presence(). ``` Sets `sub_els` field of `Stanza`. Note that the function replaces all existing sub-elements of `Stanza`: use [append_subtags/2](#append_subtags2) if you only want to add new elements. **Example 1**: setting `sub_els` field of `iq()` ```erlang > xmpp:set_els(#iq{type = get}, [#ping{}]). #iq{id = <<>>,type = get,lang = <<>>,from = undefined, to = undefined, sub_els = [#ping{}], meta = #{}} ``` **Example 2**: removing `sub_els` from `presence()` ```erlang > xmpp:set_els(#presence{sub_els = [#caps{}]}, []). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [],meta = #{}} ``` ## get_subtag/2 ```erlang -spec get_subtag(Stanza :: stanza(), Tag :: xmpp_element()) -> xmpp_element() | false. ``` Returns first sub-element of `Stanza` matching `Tag` (i.e. `xmpp_element()` or `xmlel()` element with the same tag name and namespace as `Tag`) or `false` if no such element found or decoding of the matched element has failed. **Example 1**: obtaining `disco_info()` element ```erlang > IQ. #iq{id = <<"id">>,type = result,lang = <<>>, from = undefined,to = undefined, sub_els = [#xmlel{name = <<"query">>, attrs = [{<<"node">>,<<"node">>}, {<<"xmlns">>,<<"http://jabber.org/protocol/disco#info">>}], children = [#xmlel{name = <<"feature">>, attrs = [{<<"var">>,<<"feature">>}], children = []}]}], meta = #{}} > xmpp:get_subtag(IQ, #disco_info{}). #disco_info{node = <<"node">>,identities = [], features = [<<"feature">>], xdata = []} ``` **Example 2**: obtaining non-existing element ```erlang > xmpp:get_subtag(#presence{}, #caps{}). false ``` In the example below `jid` attribute is malformed, so the function will return `false`. **Example 3**: obtaining malformed element ```erlang > IQ. #iq{id = <<>>,type = undefined,lang = <<>>,from = undefined, to = undefined, sub_els = [#xmlel{name = <<"query">>, attrs = [{<<"xmlns">>, <<"http://jabber.org/protocol/disco#items">>}], children = [#xmlel{name = <<"item">>, attrs = [{<<"jid">>,<<"@">>}, {<<"xmlns">>,<<"http://jabber.org/protocol/disco#items">>}], children = []}]}], meta = #{}} > xmpp:get_subtag(IQ, #disco_items{}). false ``` It is also possible to use the function to obtain already decoded elements as show in the following example. **Example 4**: obtaining already decoded element ```erlang > xmpp:get_subtag(#iq{sub_els = [#ping{}]}, #ping{}). #ping{} ``` ## get_subtags/2 ```erlang -spec get_subtags(Stanza :: stanza(), Tag :: xmpp_element()) -> [xmpp_element()]. ``` Same as `get_subtag/2`, but returns all elements matching `Tag`, preserving their original order. ## try_subtag/2 ```erlang -spec try_subtag(Stanza :: stanza(), Tag :: xmpp_element()) -> xmpp_element() | false. ``` Works exactly like `get_subtag/2`, but raises `{xmpp_codec, _}` exception if decoding of a matching subtag fails. **Example 1** ```erlang > Msg = #message{sub_els = [#xmlel{name = <<"iq">>}]}. #message{id = <<>>,type = normal,lang = <<>>, from = undefined,to = undefined,subject = [],body = [], thread = undefined, sub_els = [#xmlel{name = <<"iq">>,attrs = [],children = []}], meta = #{}} > xmpp:get_subtag(Msg, #iq{}). false > xmpp:try_subtag(Msg, #iq{}). ** exception error: {xmpp_codec,{missing_attr,<<"id">>,<<"iq">>, <<"jabber:client">>}} ``` ## try_subtags/2 ```erlang -spec try_subtags(Stanza :: stanza(), Tag :: xmpp_element()) -> [xmpp_element()]. ``` Same as `try_subtag/2`, but returns all elements matching `Tag`, preserving their original order. ## set_subtag/2 ```erlang -spec set_subtag(Stanza :: iq(), Tag :: xmpp_element()) -> iq(); (Stanza :: message(), Tag :: xmpp_element()) -> message(); (Stanza :: presence(), Tag :: xmpp_element()) -> presence(). ``` Inserts `Tag` into sub-elements of `Stanza`. If `Stanza` already contains an element with the same tag name and namespace as `Tag`, the first occurrence of such element is replaced by `Tag`. Otherwise `Tag` is appended to the end of the list of sub-elements. Note that even malformed element will be replaced if it is matched, because decoding is not applied during matching. **Example 1**: insertion without replacement ```erlang > xmpp:set_subtag(#presence{sub_els = [#delay{stamp = now()}]}, #nick{name = <<"nick">>}). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#delay{stamp = {1489,605315,130667}, from = undefined,desc = <<>>}, #nick{name = <<"nick">>}], meta = #{}} ``` **Example 2**: insertion with replacement ```erlang > Presence. #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#xmlel{name = <<"nick">>, attrs = [{<<"xmlns">>, <<"http://jabber.org/protocol/nick">>}], children = [{xmlcdata,<<"old">>}]}], meta = #{}} > xmpp:set_subtag(Presence, #nick{name = <<"new">>}). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#nick{name = <<"new">>}], meta = #{}} ``` In the example below existing `` tag is replaced even though it's malformed (`` element MUST possess `stamp` attribute). **Example 3**: replacement of malformed matching element ```erlang > Presence. #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#xmlel{name = <<"delay">>, attrs = [{<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}], meta = #{}} > xmpp:set_subtag(Presence, #delay{stamp = now()}). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#delay{stamp = {1489,605957,281474}, from = undefined,desc = <<>>}], meta = #{}} ``` ## remove_subtag/2 ```erlang -spec remove_subtag(Stanza :: iq(), Tag :: xmpp_element()) -> iq(); (Stanza :: message(), Tag :: xmpp_element()) -> message(); (Stanza :: presence(), Tag :: xmpp_element()) -> presence(). ``` Removes all sub-elements of `Stanza` matching `Tag` (i.e. `xmpp_element()` or `xmlel()` elements with the same tag name and namespace as `Tag`). Note that even malformed elements will be removed if they are matched, because decoding is not applied during matching. **Example 1**: removing all matching elements ```erlang > Presence. #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#xmlel{name = <<"delay">>, attrs = [{<<"stamp">>,<<"2017-03-15T20:04:50.711597Z">>}, {<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}, #xmlel{name = <<"delay">>, attrs = [{<<"stamp">>,<<"2017-03-15T20:04:50.711613Z">>}, {<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}], meta = #{}} > xmpp:remove_subtag(Presence, #delay{}). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [],meta = #{}} ``` In the example below `` tag is removed even though it's malformed (`` element MUST possess `stamp` attribute). **Example 2**: removing malformed matching element ```erlang > Presence. #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#xmlel{name = <<"delay">>, attrs = [{<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}], meta = #{}} > xmpp:remove_subtag(Presence, #delay{}). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [],meta = #{}} ``` ## has_subtag/2 ```erlang -spec has_subtag(Stanza :: stanza(), Tag :: xmpp_element()) -> boolean(). ``` Returns `true` if there exists a sub-element of `Stanza` matching `Tag` (i.e. an `xmpp_element()` or `xmlel()` element with the same tag name and namespace as `Tag`). Otherwise returns `false`. Note that `true` is returned even if matched element is malformed, because decoding is not applied during matching. **Example 1**: found matching element ```erlang > Presence. #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#xmlel{name = <<"delay">>, attrs = [{<<"stamp">>,<<"2017-03-15T20:31:17.911811Z">>}, {<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}], meta = #{}} > xmpp:has_subtag(Presence, #delay{}). true ``` **Example 2**: no matching elements found ```erlang > xmpp:has_subtag(#presence{}, #delay{}). false ``` In the example below `` element is considered as being matched even though it's malformed (`` element MUST possess `stamp` attribute). **Example 3**: found matching malformed element ```erlang > Presence. #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#xmlel{name = <<"delay">>, attrs = [{<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}], meta = #{}} > xmpp:has_subtag(Presence, #delay{}). true. ``` ## append_subtags/2 ```erlang -spec append_subtags(Stanza :: iq(), Els :: [xmpp_element() | xmlel()]) -> iq(); (Stanza :: message(), Els :: [xmpp_element() | xmlel()]) -> message(); (Stanza :: presence(), Els :: [xmpp_element() | xmlel()]) -> presence(). ``` Appends a list of elements `Els` to the end of a list of sub-elements of `Stanza`. **Example 1**: appending elements ```erlang > Els. [#xmlel{name = <<"delay">>, attrs = [{<<"stamp">>,<<"2017-03-15T20:39:26.339167Z">>}, {<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}, #stanza_error{type = modify,code = 400,by = <<>>, reason = 'bad-request',text = undefined,sub_els = []}] > xmpp:append_subtags(#presence{sub_els = [#caps{}]}, Els). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined, sub_els = [#caps{node = <<>>,version = <<>>,hash = <<>>, exts = []}, #xmlel{name = <<"delay">>, attrs = [{<<"stamp">>,<<"2017-03-15T20:39:26.339167Z">>}, {<<"xmlns">>,<<"urn:xmpp:delay">>}], children = []}, #stanza_error{type = modify,code = 400,by = <<>>, reason = 'bad-request',text = undefined,sub_els = []}], meta = #{}} ``` ## get_meta/1 ```erlang -spec get_meta(Stanza :: stanza()) -> Meta :: map(). ``` Returns metadata associated with `Stanza` (that is, the value of its `meta` field). **Example 1**: obtaining metadata ```erlang > xmpp:get_meta(#presence{meta = #{foo => bar}}). #{foo => bar} ``` ## get_meta/2 ```erlang -spec get_meta(Stanza :: stanza(), Key :: any()) -> Value :: any(). ``` Returns value `Value` associated with `Key` if metadata of `Stanza` contains `Key`. Fails with a `{badkey, Key}` exception otherwise. **Example 1**: obtaining a value ```erlang > xmpp:get_meta(#presence{meta = #{foo => bar}}, foo). bar ``` **Example 2**: key not found ```erlang > xmpp:get_meta(#presence{meta = #{foo => bar}}, bar). ** exception error: {badkey,bar} ... ``` ## get_meta/3 ```erlang -spec get_meta(Stanza :: stanza(), Key :: any(), Default :: any()) -> Value :: any(). ``` Returns value `Value` associated with `Key` if metadata of `Stanza` contains `Key`. If no value is associated with `Key`, `Default` is returned. **Example 1**: obtaining a value ```erlang > xmpp:get_meta(#presence{meta = #{foo => bar}}, foo, undefined). bar ``` **Example 2**: key not found ```erlang > xmpp:get_meta(#presence{meta = #{foo => bar}}, bar, undefined). undefined ``` ## set_meta/2 ```erlang -spec set_meta(Stanza :: stanza(), Meta :: map()) -> stanza(). ``` Sets metadata of `Stanza`. **Example 1**: setting metadata ```erlang > xmpp:set_meta(#presence{}, #{foo => bar}). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [], meta = #{foo => bar}} ``` **Example 2**: removing entire metadata ```erlang > xmpp:set_meta(#presence{meta = #{foo => bar}}, #{}). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [],meta = #{}} ``` ## put_meta/3 ```erlang -spec put_meta(Stanza :: stanza(), Key :: any(), Value :: any()) -> stanza(). ``` Associates `Key` with value `Value` and inserts the association into metadata of `Stanza`. **Example 1**: sets new key in metadata ```erlang > xmpp:put_meta(#presence{}, foo, bar). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [], meta = #{foo => bar}} ``` **Example 2**: replacing existing key in metadata ```erlang > xmpp:put_meta(#presence{meta = #{foo => bar}}, foo, baz). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [], meta = #{foo => baz}} ``` ## update_meta/3 ```erlang -spec update_meta(Stanza :: stanza(), Key :: any(), Value :: any()) -> Stanza :: stanza(). ``` If `Key` exists in metadata of `Stanza`, the old associated value is replaced by value `Value`. Fails with `{badkey,Key}` exception if no value is associated with `Key`. **Example 1**: updating existing key ```erlang > xmpp:update_meta(#presence{meta = #{foo => bar}}, foo, baz). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [], meta = #{foo => baz}} ``` **Example 2**: updating non-existing key ```erlang > xmpp:update_meta(#presence{}, foo, bar). ** exception error: {badkey,foo} ... ``` ## del_meta/2 ```erlang -spec del_meta(Stanza :: stanza(), Key :: any()) -> stanza(). ``` Removes the `Key`, if it exists, and its associated value from metadata of `Stanza`. **Example 1**: removing value by key ```erlang > xmpp:del_meta(#presence{meta = #{foo => bar}}, foo). #presence{id = <<>>,type = available,lang = <<>>, from = undefined,to = undefined,show = undefined, status = [],priority = undefined,sub_els = [],meta = #{}} ``` ## is_stanza/1 ```erlang -spec is_stanza(Term :: any()) -> boolean(). ``` Returns `true` if `Term` is either of type `stanza()` or an `xmlel()` element representing stanza. Returns `false` otherwise. **Examples**: ```erlang > xmpp:is_stanza(#iq{}). true > xmpp:is_stanza(#disco_info{}). false. > xmpp:is_stanza(123). false. > xmpp:is_stanza(#xmlel{name = <<"message">>}). true > xmpp:is_stanza(#xmlel{name = <<"foo">>}). false. ``` ## is_known_tag/1 ```erlang -spec is_known_tag(El :: xmlel()) -> boolean(). ``` Shorthand for `is_known_tag(El, ?NS_CLIENT)`. ## is_known_tag/2 ```erlang -spec is_known_tag(El :: xmlel(), Namespace :: binary()) -> boolean(). ``` Returns `true` if `El` has corresponding `xmpp_element()`. Otherwise returns `false`. If `El` doesn't possess an `xmlns` attribute it's assumed that it is within namespace `Namespace`. > **NOTE**: if `El` is considered known doesn't mean it's valid: > decoding may still fail. **Example 1**: the tag is known ```erlang > xmpp:is_known_tag(#xmlel{name = <<"x">>, attrs = [{<<"xmlns">>,<<"http://jabber.org/protocol/muc">>}]}). true ``` **Example 2**: the tag is unknown ```erlang > xmpp:is_known_tag(#xmlel{name = <<"foo">>, attrs = [{<<"xmlns">>,<<"bar">>}]}). false ``` **Example 3**: the element lacks namespace, so it's always unknown ```erlang > xmpp:is_known_tag(#xmlel{name = <<"x">>}). false ``` **Example 4**: the element lacks namespace, but we assume it's within 'jabber:server' namespace ```erlang > xmpp:is_known_tag(#xmlel{name = <<"message">>}, <<"jabber:server">>). true ``` ## get_ns/1 ```erlang -spec get_ns(El :: xmpp_element() | xmlel()) -> Namespace :: binary(). ``` Returns namespace of `xmpp_element()` or `xmlel()` element. **Example 1**: obtaining namespace of `xmpp_element()` ```erlang > xmpp:get_ns(#disco_info{}). <<"http://jabber.org/protocol/disco#info">> ``` **Example 2**: obtaining namespace of `xmlel()` element ```erlang > xmpp:get_ns(#xmlel{attrs = [{<<"xmlns">>, <<"foo:bar">>}]}). <<"foo:bar">> ``` ## get_name/1 ```erlang -spec get_name(xmpp_element() | xmlel()) -> binary(). ``` Returns tag name of `xmpp_element()` or `xmlel()` element. **Example 1**: obtaining tag name of `xmpp_element()` ```erlang > xmpp:get_name(#disco_info{}). <<"query">> > xmpp:get_name(#chatstate{type = composing}). <<"composing">> ``` **Example 2**: obtaining tag name of `xmlel()` element ```erlang > xmpp:get_name(#xmlel{name = <<"some">>}). <<"some">> ``` ## make_iq_result/1 ```erlang -spec make_iq_result(IQ :: iq()) -> iq(). ``` Creates from `IQ` an `iq()` of type `result` with empty sub-elements. > **WARNING**: only `iq()` of type `set` or `get` should be provided, > otherwise the function will fail **Example 1**: creating a result ```erlang > xmpp:make_iq_result(#iq{type = get, id = <<"1">>, sub_els = [#ping{}]}). #iq{id = <<"1">>,type = result,lang = <<>>,from = undefined, to = undefined,sub_els = [],meta = #{}} ``` **Example 2**: trying to create a result of a result ```erlang > xmpp:make_iq_result(#iq{type = result, id = <<"1">>}). ** exception error: no function clause matching ``` ## make_iq_result/2 ```erlang -spec make_iq_result(IQ :: iq(), El :: xmpp_element() | xmlel()) -> iq(). ``` Creates from `IQ` an `iq()` of type `result` with sub-elements set to `[El]`. > **WARNING**: only `iq()` of type `set` or `get` should be provided, > otherwise the function will fail **Example 1**: creating a result ```erlang > xmpp:make_iq_result(#iq{type = get, id = <<"1">>}, #disco_info{features = [<<"feature">>]}). #iq{id = <<"1">>,type = result,lang = <<>>,from = undefined, to = undefined, sub_els = [#disco_info{node = <<>>,identities = [], features = [<<"feature">>], xdata = []}], meta = #{}} ``` **Example 2**: trying to create a result of a result ```erlang > xmpp:make_iq_result(#iq{type = result, id = <<"1">>}, #disco_items{}). ** exception error: no function clause matching ``` ## make_error/2 ```erlang -spec make_error(Stanza :: stanza(), stanza_error() | xmlel()) -> stanza(); (El :: xmlel(), stanza_error() | xmlel()) -> xmlel(). ``` Constructs `stanza()` of type `error` from `Stanza`. > **WARNING**: `Stanza` should not have type `error` or `result`, > otherwise the function will fail **Example 1**: creating message-error ```erlang > xmpp:make_error(#message{type = chat}, xmpp:err_bad_request()). #message{id = <<>>,type = error,lang = <<>>, from = undefined,to = undefined,subject = [],body = [], thread = undefined, sub_els = [#stanza_error{type = modify,code = 400,by = <<>>, reason = 'bad-request',text = undefined,sub_els = []}], meta = #{}} ``` **Example 2**: trying to create an error from an error ```erlang > xmpp:make_error(#presence{type = error}, xmpp:err_bad_request()). ** exception error: no function clause matching ``` ## get_error/1 ```erlang -spec get_error(Stanza :: stanza()) -> undefined | stanza_error(). ``` Returns `stanza_error()` sub-element from `Stanza` or `undefined` if not found of if decoding has failed. **Example 1**: extracting `stanza_error()` element ```erlang > Err. #xmlel{name = <<"error">>, attrs = [{<<"code">>,<<"400">>},{<<"type">>,<<"modify">>}], children = [#xmlel{name = <<"bad-request">>, attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-stanzas">>}], children = []}]} > xmpp:get_error(#message{sub_els = [Err]}). #stanza_error{type = modify,code = 400,by = <<>>, reason = 'bad-request',text = undefined,sub_els = []} ``` **Example 2**: no `stanza_error()` element found ```erlang > xmpp:get_error(#message{}). undefined ``` ## format_error/1 ```erlang -spec format_error(_) -> binary(). ``` Creates diagnostic text from an error generated by [decode/1](#decode1) or [decode/3](#decode3). **Examples**: ```erlang > try xmpp:decode(#xmlel{name = <<"foo">>}) catch _:{xmpp_codec, Reason} -> xmpp:format_error(Reason) end. <<"Unknown tag qualified by namespace 'jabber:client'">> > try xmpp:decode(#xmlel{name = <<"iq">>}) catch _:{xmpp_codec, Reason} -> xmpp:format_error(Reason) end. <<"Missing attribute 'id' in tag qualified by namespace 'jabber:client'">> > try xmpp:decode(#xmlel{name = <<"x">>}, <<>>, []) catch _:{xmpp_codec, Reason} -> xmpp:format_error(Reason) end. <<"Missing namespace for tag ">> ``` ## io_format_error/1 ```erlang -spec io_format_error(_) -> {binary(), [binary()]}. ``` Same as [format_error/1](#format_error1), but result is suitable for using in formatting functions from [io](http://erlang.org/doc/man/io.html) or [io_lib](http://erlang.org/doc/man/io_lib.html) modules. **Example**: ```erlang > {Format, Args} = try xmpp:decode(#xmlel{name = <<"iq">>}) catch _:{xmpp_codec, Reason} -> xmpp:io_format_error(Reason) end. {<<"Missing attribute '~s' in tag <~s/> qualified by namespace '~s'">>, [<<"id">>,<<"iq">>,<<"jabber:client">>]} > io:format(Format, Args). Missing attribute 'id' in tag qualified by namespace 'jabber:client' ``` ## format_stanza_error/1 ```erlang -spec format_stanza_error(Err :: stanza_error()) -> binary(). ``` Same as `format_stanza_error(Err, <<"en">>)`. ## format_stanza_error/2 ```erlang -spec format_stanza_error(Err :: stanza_error(), Lang :: binary()) -> binary(). ``` Creates diagnostic text from `stanza_error()` element. **Example**: ```erlang > Err. #stanza_error{type = cancel,code = 501,by = <<>>, reason = 'feature-not-implemented', text = [#text{lang = <<"en">>, data = <<"Unsupported query">>}], sub_els = []} > xmpp:format_stanza_error(Err, <<"en">>). <<"Unsupported query (feature-not-implemented)">> ``` ## format_stream_error/1 ```erlang -spec format_stream_error(Err :: stream_error()) -> binary(). ``` Same as `format_stream_error(Err, <<"en">>)`. ## format_stream_error/2 ```erlang -spec format_stream_error(Err :: stream_error(), Lang :: binary()) -> binary(). ``` Creates diagnostic text from `stream_error()` element. **Example**: ```erlang > Err. #stream_error{reason = 'policy-violation', text = [#text{lang = <<"en">>, data = <<"Too many connections">>}]} > xmpp:format_stream_error(Err, <<"en">>). <<"Too many connections (policy-violation)">> ``` ## format_sasl_error/1 ```erlang -spec format_sasl_error(Err :: sasl_failure()) -> binary(). ``` Same as `format_sasl_error(Err, <<"en">>)`. ## format_sasl_error/2 ```erlang -spec format_sasl_error(Err :: sasl_failure(), Lang :: binary()) -> binary(). ``` Creates diagnostic text from `sasl_failure()` element. **Example**: ```erlang > Err. #sasl_failure{reason = 'not-authorized', text = [#text{lang = <<"en">>, data = <<"Invalid username">>}]} > xmpp:format_sasl_error(Err, <<"en">>). <<"Invalid username (not-authorized)">> ``` ## pp/1 ```erlang -spec pp(any()) -> iodata(). ``` Pretty printer for XMPP elements. **Example**: ```erlang > S = xmpp:pp(#sm_a{h = 10, xmlns = <<"urn:xmpp:sm:3">>}). ["#sm_a",123, [["h"," = ",49,48], 44, ["xmlns"," = ",60,60,"\"urn:xmpp:sm:3\"",62,62]], 125] > io:format(S). #sm_a{h = 10,xmlns = <<"urn:xmpp:sm:3">>} ``` ## set_tr_callback/1 ```erlang -spec set_tr_callback({Module :: module(), Function :: atom()} | undefined) -> ok. ``` Installs `Module:Function/2` as a callback translation function or uninstalls the callback if `undefined` is provided. The callback function should be defined as: ```erlang -spec Module:Function(Lang :: binary(), TextIn :: binary()) -> TextOut :: binary(). ``` where `Lang` is a language tag, `TextIn` is a text to be translated and `TextOut` is a resulting translated text. By default, no translation callback is set and thus translation is not performed. **Example 1**: installing the callback ```erlang > xmpp:mk_text(<<"hello">>, <<"ru">>). [#text{lang = <<"en">>,data = <<"hello">>}] > my_trans_mod:trans(<<"ru">>, <<"hello">>). <<"привет">>. > xmpp:set_tr_callback({my_trans_mod, trans}). ok > xmpp:mk_text(<<"hello">>, <<"ru">>). [#text{lang = <<"ru">>,data = <<"привет">>}, #text{lang = <<"en">>,data = <<"hello">>}] ``` **Example 2**: uninstalling any callback ```erlang > xmpp:mk_text(<<"hello">>, <<"ru">>). [#text{lang = <<"ru">>,data = <<"привет">>}, #text{lang = <<"en">>,data = <<"hello">>}] > xmpp:set_tr_callback(undefined). ok > xmpp:mk_text(<<"hello">>, <<"ru">>). [#text{lang = <<"en">>,data = <<"hello">>}] ``` ## get_text/1 ```erlang -spec get_text(Text :: [text()]) -> binary(). ``` Shorthand for `get_text(Text, <<"en">>)`. ## get_text/2 ```erlang -spec get_text(Text :: [text()], Lang :: binary()) -> binary(). ``` Extracts data from a list of `text()` elements, tagged by language `Lang`. **Example**: ```erlang > Text. [#text{lang = <<"en">>,data = <<"hello">>}, #text{lang = <<"ru">>,data = <<"привет">>}] > xmpp:get_text(Text, <<"ru">>). <<"привет">> > xmpp:get_text(Text, <<"en">>). <<"hello">> > xmpp:get_text(Text, <<"fr">>). <<"hello">> ``` ## mk_text/1 ```erlang -spec mk_text(Text :: binary() | {io:format(), list()}) -> [text()]. ``` Shorthand for `mk_text(Text, <<"en">>)`. ## mk_text/2 ```erlang -spec mk_text(binary() | {io:format(), list()}, Lang :: binary()) -> [text()]. ``` Creates a list of a single `text()` element from `binary()` or formatted text, translated into language `Lang` using a callback function set in [set_tr_callback/1](#set_tr_callback1). **Example**: ```erlang > xmpp:mk_text(<<"hello">>, <<"en">>). [#text{lang = <<"en">>, data = <<"hello">>}] > xmpp:mk_text({"hello, ~s!", ["Bob"]}, <<"en">>). [#text{lang = <<"en">>, data = <<"hello, Bob!">>}] ``` ## err_bad_request/0 ```erlang -spec err_bad_request() -> stanza_error() ``` Creates 'bad-request' stanza error. ## err_bad_request/2 ```erlang -spec err_bad_request( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'bad-request' stanza error. ## err_conflict/0 ```erlang -spec err_conflict() -> stanza_error() ``` Creates 'conflict' stanza error. ## err_conflict/2 ```erlang -spec err_conflict( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'conflict' stanza error. ## err_feature_not_implemented/0 ```erlang -spec err_feature_not_implemented() -> stanza_error() ``` Creates 'feature-not-implemented' stanza error. ## err_feature_not_implemented/2 ```erlang -spec err_feature_not_implemented( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'feature-not-implemented' stanza error. ## err_forbidden/0 ```erlang -spec err_forbidden() -> stanza_error() ``` Creates 'forbidden' stanza error. ## err_forbidden/2 ```erlang -spec err_forbidden( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'forbidden' stanza error. ## err_gone/1 ```erlang -spec err_gone(URI :: binary()) -> stanza_error() ``` Creates 'gone' stanza error. `URI` is a Uniform or Internationalized Resource Identifier, typically an XMPP IRI. ## err_gone/3 ```erlang -spec err_gone( URI :: binary(), Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'gone' stanza error. `URI` is a Uniform or Internationalized Resource Identifier, typically an XMPP IRI. ## err_internal_server_error/0 ```erlang -spec err_internal_server_error() -> stanza_error() ``` Creates 'internal-server-error' stanza error. ## err_internal_server_error/2 ```erlang -spec err_internal_server_error( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'internal-server-error' stanza error. ## err_item_not_found/0 ```erlang -spec err_item_not_found() -> stanza_error() ``` Creates 'item-not-found' stanza error. ## err_item_not_found/2 ```erlang -spec err_item_not_found( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'item-not-found' stanza error. ## err_jid_malformed/0 ```erlang -spec err_jid_malformed() -> stanza_error() ``` Creates 'jid-malformed' stanza error. ## err_jid_malformed/2 ```erlang -spec err_jid_malformed( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'jid-malformed' stanza error. ## err_not_acceptable/0 ```erlang -spec err_not_acceptable() -> stanza_error() ``` Creates 'not-acceptable' stanza error. ## err_not_acceptable/2 ```erlang -spec err_not_acceptable( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'not-acceptable' stanza error. ## err_not_allowed/0 ```erlang -spec err_not_allowed() -> stanza_error() ``` Creates 'not-allowed' stanza error. ## err_not_allowed/2 ```erlang -spec err_not_allowed( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'not-allowed' stanza error. ## err_not_authorized/0 ```erlang -spec err_not_authorized() -> stanza_error() ``` Creates 'not-authorized' stanza error. ## err_not_authorized/2 ```erlang -spec err_not_authorized( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'not-authorized' stanza error. ## err_payment_required/0 ```erlang -spec err_payment_required() -> stanza_error() ``` Creates 'payment-required' stanza error. ## err_payment_required/2 ```erlang -spec err_payment_required( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'payment-required' stanza error. ## err_policy_violation/0 ```erlang -spec err_policy_violation() -> stanza_error() ``` Creates 'policy-violation' stanza error. ## err_policy_violation/2 ```erlang -spec err_policy_violation( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'policy-violation' stanza error. ## err_recipient_unavailable/0 ```erlang -spec err_recipient_unavailable() -> stanza_error() ``` Creates 'recipient-unavailable' stanza error. ## err_recipient_unavailable/2 ```erlang -spec err_recipient_unavailable( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'recipient-unavailable' stanza error. ## err_redirect/1 ```erlang -spec err_redirect(URI :: binary()) -> stanza_error() ``` Creates 'redirect' stanza error. `URI` is a Uniform or Internationalized Resource Identifier, typically an XMPP IRI. ## err_redirect/3 ```erlang -spec err_redirect( URI :: binary(), Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'redirect' stanza error. `URI` is a Uniform or Internationalized Resource Identifier, typically an XMPP IRI. ## err_registration_required/0 ```erlang -spec err_registration_required() -> stanza_error() ``` Creates 'registration-required' stanza error. ## err_registration_required/2 ```erlang -spec err_registration_required( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'registration-required' stanza error. ## err_remote_server_not_found/0 ```erlang -spec err_remote_server_not_found() -> stanza_error() ``` Creates 'remote-server-not-found' stanza error. ## err_remote_server_not_found/2 ```erlang -spec err_remote_server_not_found( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'remote-server-not-found' stanza error. ## err_remote_server_timeout/0 ```erlang -spec err_remote_server_timeout() -> stanza_error() ``` Creates 'remote-server-timeout' stanza error. ## err_remote_server_timeout/2 ```erlang -spec err_remote_server_timeout( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'remote-server-timeout' stanza error. ## err_resource_constraint/0 ```erlang -spec err_resource_constraint() -> stanza_error() ``` Creates 'resource-constraint' stanza error. ## err_resource_constraint/2 ```erlang -spec err_resource_constraint( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'resource-constraint' stanza error. ## err_service_unavailable/0 ```erlang -spec err_service_unavailable() -> stanza_error() ``` Creates 'service-unavailable' stanza error. ## err_service_unavailable/2 ```erlang -spec err_service_unavailable( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'service-unavailable' stanza error. ## err_subscription_required/0 ```erlang -spec err_subscription_required() -> stanza_error() ``` Creates 'subscription-required' stanza error. ## err_subscription_required/2 ```erlang -spec err_subscription_required( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'subscription-required' stanza error. ## err_undefined_condition/1 ```erlang -spec err_undefined_condition( Type :: 'auth' | 'cancel' | 'continue' | 'modify' | 'wait') -> stanza_error() ``` Creates 'undefined-condition' stanza error. ## err_undefined_condition/3 ```erlang -spec err_undefined_condition( Type :: 'auth' | 'cancel' | 'continue' | 'modify' | 'wait', Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'undefined-condition' stanza error. ## err_unexpected_request/0 ```erlang -spec err_unexpected_request() -> stanza_error() ``` Creates 'unexpected-request' stanza error. ## err_unexpected_request/2 ```erlang -spec err_unexpected_request( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stanza_error() ``` Creates 'unexpected-request' stanza error. ## serr_bad_format/0 ```erlang -spec serr_bad_format() -> stream_error() ``` Creates 'bad-format' stream error. ## serr_bad_format/2 ```erlang -spec serr_bad_format( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'bad-format' stream error. ## serr_bad_namespace_prefix/0 ```erlang -spec serr_bad_namespace_prefix() -> stream_error() ``` Creates 'bad-namespace-prefix' stream error. ## serr_bad_namespace_prefix/2 ```erlang -spec serr_bad_namespace_prefix( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'bad-namespace-prefix' stream error. ## serr_conflict/0 ```erlang -spec serr_conflict() -> stream_error() ``` Creates 'conflict' stream error. ## serr_conflict/2 ```erlang -spec serr_conflict( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'conflict' stream error. ## serr_connection_timeout/0 ```erlang -spec serr_connection_timeout() -> stream_error() ``` Creates 'connection-timeout' stream error. ## serr_connection_timeout/2 ```erlang -spec serr_connection_timeout( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'connection-timeout' stream error. ## serr_host_gone/0 ```erlang -spec serr_host_gone() -> stream_error() ``` Creates 'host-gone' stream error. ## serr_host_gone/2 ```erlang -spec serr_host_gone( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'host-gone' stream error. ## serr_host_unknown/0 ```erlang -spec serr_host_unknown() -> stream_error() ``` Creates 'host-unknown' stream error. ## serr_host_unknown/2 ```erlang -spec serr_host_unknown( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'host-unknown' stream error. ## serr_improper_addressing/0 ```erlang -spec serr_improper_addressing() -> stream_error() ``` Creates 'improper-addressing' stream error. ## serr_improper_addressing/2 ```erlang -spec serr_improper_addressing( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'improper-addressing' stream error. ## serr_internal_server_error/0 ```erlang -spec serr_internal_server_error() -> stream_error() ``` Creates 'internal-server-error' stream error. ## serr_internal_server_error/2 ```erlang -spec serr_internal_server_error( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'internal-server-error' stream error. ## serr_invalid_from/0 ```erlang -spec serr_invalid_from() -> stream_error() ``` Creates 'invalid-from' stream error. ## serr_invalid_from/2 ```erlang -spec serr_invalid_from( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'invalid-from' stream error. ## serr_invalid_id/0 ```erlang -spec serr_invalid_id() -> stream_error() ``` Creates 'invalid-id' stream error. ## serr_invalid_id/2 ```erlang -spec serr_invalid_id( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'invalid-id' stream error. ## serr_invalid_namespace/0 ```erlang -spec serr_invalid_namespace() -> stream_error() ``` Creates 'invalid-namespace' stream error. ## serr_invalid_namespace/2 ```erlang -spec serr_invalid_namespace( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'invalid-namespace' stream error. ## serr_invalid_xml/0 ```erlang -spec serr_invalid_xml() -> stream_error() ``` Creates 'invalid-xml' stream error. ## serr_invalid_xml/2 ```erlang -spec serr_invalid_xml( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'invalid-xml' stream error. ## serr_not_authorized/0 ```erlang -spec serr_not_authorized() -> stream_error() ``` Creates 'not-authorized' stream error. ## serr_not_authorized/2 ```erlang -spec serr_not_authorized( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'not-authorized' stream error. ## serr_not_well_formed/0 ```erlang -spec serr_not_well_formed() -> stream_error() ``` Creates 'not-well-formed' stream error. ## serr_not_well_formed/2 ```erlang -spec serr_not_well_formed( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'not-well-formed' stream error. ## serr_policy_violation/0 ```erlang -spec serr_policy_violation() -> stream_error() ``` Creates 'policy-violation' stream error. ## serr_policy_violation/2 ```erlang -spec serr_policy_violation( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'policy-violation' stream error. ## serr_remote_connection_failed/0 ```erlang -spec serr_remote_connection_failed() -> stream_error() ``` Creates 'remote-connection-failed' stream error. ## serr_remote_connection_failed/2 ```erlang -spec serr_remote_connection_failed( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'remote-connection-failed' stream error. ## serr_reset/0 ```erlang -spec serr_reset() -> stream_error() ``` Creates 'reset' stream error. ## serr_reset/2 ```erlang -spec serr_reset( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'reset' stream error. ## serr_resource_constraint/0 ```erlang -spec serr_resource_constraint() -> stream_error() ``` Creates 'resource-constraint' stream error. ## serr_resource_constraint/2 ```erlang -spec serr_resource_constraint( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'resource-constraint' stream error. ## serr_restricted_xml/0 ```erlang -spec serr_restricted_xml() -> stream_error() ``` Creates 'restricted-xml' stream error. ## serr_restricted_xml/2 ```erlang -spec serr_restricted_xml( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'restricted-xml' stream error. ## serr_see_other_host/1 ```erlang -spec serr_see_other_host(HostPort :: xmpp_host()) -> stream_error() ``` where `xmpp_host()` is defined as ```erlang -type xmpp_host() :: binary() | inet:ip_address() | {binary() | inet:ip_address(), inet:port_number()}. ``` Creates 'see-other-host' stream error. `HostPort` is a hostname or IP address (with or without a port). ## serr_see_other_host/3 ```erlang -spec serr_see_other_host( HostPort :: xmpp_host(), Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` where `xmpp_host()` is defined as ```erlang -type xmpp_host() :: binary() | inet:ip_address() | {binary() | inet:ip_address(), inet:port_number()}. ``` Creates 'see-other-host' stream error. `HostPort` is a hostname or IP address (with or without a port). ## serr_system_shutdown/0 ```erlang -spec serr_system_shutdown() -> stream_error() ``` Creates 'system-shutdown' stream error. ## serr_system_shutdown/2 ```erlang -spec serr_system_shutdown( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'system-shutdown' stream error. ## serr_undefined_condition/0 ```erlang -spec serr_undefined_condition() -> stream_error() ``` Creates 'undefined-condition' stream error. ## serr_undefined_condition/2 ```erlang -spec serr_undefined_condition( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'undefined-condition' stream error. ## serr_unsupported_encoding/0 ```erlang -spec serr_unsupported_encoding() -> stream_error() ``` Creates 'unsupported-encoding' stream error. ## serr_unsupported_encoding/2 ```erlang -spec serr_unsupported_encoding( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'unsupported-encoding' stream error. ## serr_unsupported_feature/0 ```erlang -spec serr_unsupported_feature() -> stream_error() ``` Creates 'unsupported-feature' stream error. ## serr_unsupported_feature/2 ```erlang -spec serr_unsupported_feature( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'unsupported-feature' stream error. ## serr_unsupported_stanza_type/0 ```erlang -spec serr_unsupported_stanza_type() -> stream_error() ``` Creates 'unsupported-stanza-type' stream error. ## serr_unsupported_stanza_type/2 ```erlang -spec serr_unsupported_stanza_type( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'unsupported-stanza-type' stream error. ## serr_unsupported_version/0 ```erlang -spec serr_unsupported_version() -> stream_error() ``` Creates 'unsupported-version' stream error. ## serr_unsupported_version/2 ```erlang -spec serr_unsupported_version( Desc :: binary() | {io:format(), list()}, Lang :: binary()) -> stream_error() ``` Creates 'unsupported-version' stream error. ## xmpp_util The following functions are exported from `xmpp_util` module: - [decode_timestamp/1](#decode_timestamp1) - [encode_timestamp/1](#encode_timestamp1) - [get_xdata_values/2](#get_xdata_values2) - [set_xdata_field/2](#set_xdata_field2) - [has_xdata_var/2](#has_xdata_var2) ## decode_timestamp/1 ```erlang -spec decode_timestamp(Data :: binary()) -> erlang:timestamp(). ``` Decodes timestamp from [XEP-0082](https://xmpp.org/extensions/xep-0082.html) format (both `DateTime` and legacy) into `erlang:timestamp()` format. Fails with `{bad_timestamp, Data}` exception if `Data` doesn't represent a valid timestamp. **Example 1**: decoding from `DateTime` format ```erlang > xmpp_util:decode_timestamp(<<"2006-12-19T17:58:35Z">>). {1166,551115,0} ``` **Example 2**: decoding from legacy format ```erlang > xmpp_util:decode_timestamp(<<"20020910T17:58:35">>). {1031,680715,0} ``` **Example 3**: decoding failure - not even remotely a timestamp ```erlang > xmpp_util:decode_timestamp(<<"sd324klsjdpsdf">>). ** exception error: {bad_timestamp,<<"sd324klsjdpsdf">>} ... ``` **Example 4**: decoding failure - month is invalid ```erlang > xmpp_util:decode_timestamp(<<"2006-13-19T17:58:35Z">>). ** exception error: {bad_timestamp,<<"2006-13-19T17:58:35Z">>} ... ``` ## encode_timestamp/1 ```erlang -spec encode_timestamp(Timestamp :: erlang:timestamp()) -> binary(). ``` Encodes `Timestamp` into `DateTime` format of [XEP-0082](https://xmpp.org/extensions/xep-0082.html). **Example**: ```erlang > xmpp_util:encode_timestamp({1166,551115,34}). <<"2006-12-19T17:58:35.000034Z">> ``` ## get_xdata_values/2 ```erlang -spec get_xdata_values(Var :: binary(), Form :: xdata()) -> Values :: [binary()]. ``` Returns `Values` associated with `Var` field of a data form `Form`. **Example**: obtaining values ```erlang > Form. #xdata{type = submit,instructions = [],title = undefined, reported = undefined,items = [], fields = [#xdata_field{label = <<>>,type = 'text-single', var = <<"search_request">>,required = false,desc = <<>>, values = [<<"verona">>], options = [],sub_els = []}]} > xmpp_util:get_xdata_values(<<"search_request">>, Form). [<<"verona">>] > xmpp_util:get_xdata_values(<<"non_existent">>, Form). [] ``` ## set_xdata_field/2 ```erlang -spec set_xdata_field(Field :: xdata_field(), Form :: xdata()) -> xdata(). ``` Sets `Field` in a data form `Form`. If there is already field matching `Field` exists (i.e. has the same value of `#xdata_field.var`), then it's replaced. Otherwise `Field` is appended to the end of `Form#xdata.fields` list. **Example 1**: setting new field ```erlang > xmpp_util:set_xdata_field(#xdata_field{var = <<"var">>, values = [<<"val">>]}, #xdata{}). #xdata{type = undefined,instructions = [],title = undefined, reported = undefined,items = [], fields = [#xdata_field{label = <<>>,type = undefined, var = <<"var">>,required = false,desc = <<>>, values = [<<"val">>], options = [],sub_els = []}]} ``` **Example 2**: replacing existing field ```erlang > xmpp_util:set_xdata_field(#xdata_field{var = <<"var">>, values = [<<"new">>]}, #xdata{fields = [#xdata_field{var = <<"var">>, values = [<<"old">>]}]}). #xdata{type = undefined,instructions = [],title = undefined, reported = undefined,items = [], fields = [#xdata_field{label = <<>>,type = undefined, var = <<"var">>,required = false,desc = <<>>, values = [<<"new">>], options = [],sub_els = []}]} ``` ## has_xdata_var/2 ```erlang -spec has_xdata_var(Var :: binary(), Form :: xdata()) -> boolean(). ``` Returns `true` if there is `xdata_field()` exists in the `Form` with value of `#xdata_field.var` field matching `Var`. Returns `false` otherwise. **Example 1**: the field exists ```erlang > xmpp_util:has_xdata_var(<<"var">>, #xdata{fields = [#xdata_field{var = <<"var">>, values = [<<"old">>]}]}). true ``` **Example 2**: the field doesn't exist ```erlang > xmpp_util:has_xdata_var(<<"var">>, #xdata{}). false ``` # jid The following functions are exported from `jid` module: - [decode/1](#decode1-1) - [encode/1](#encode1-1) - [make/1](#make1) - [make/2](#make2) - [make/3](#make3) - [nodeprep/1](#nodeprep1) - [nameprep/1](#nameprep1) - [resourceprep/1](#resourceprep1) - [tolower/1](#tolower1) - [split/1](#split1) - [remove_resource/1](#remove_resource1) - [replace_resource/2](#replace_resource2) ## decode/1 ```erlang -spec decode(Data :: binary()) -> jid(). ``` Decodes `Data` into JID. Fails with `{bad_jid, Data}` on failure. **Example 1**: successful decoding ```erlang > jid:decode(<<"User@Server/Resource">>). #jid{user = <<"User">>,server = <<"Server">>, resource = <<"Resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"Resource">>} ``` **Example 2**: decoding failure ```erlang > jid:decode(<<"@server">>). ** exception error: {bad_jid,<<"@server">>} ... ``` ## encode/1 ```erlang -spec encode(jid() | ljid()) -> binary(). ``` Encodes JID. **Example 1**: encoding `jid()` ```erlang > JID. #jid{user = <<"User">>,server = <<"Server">>, resource = <<"Resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"Resource">>} > jid:encode(J). <<"User@Server/Resource">> ``` **Example 2**: encoding `ljid()` ```erlang > jid:encode({<<"user">>, <<"server">>, <<"resource">>}). <<"user@server/resource">> ``` ## make/1 ```erlang -spec make(ljid() | binary()) -> jid() | error. ``` Creates `jid()` from `ljid()` or from namepart. Returns `error` if stringprep has failed. **Example 1**: creating `jid()` from `ljid()` ```erlang > jid:make({<<"User">>, <<"Server">>, <<"Resource">>}). #jid{user = <<"User">>,server = <<"Server">>, resource = <<"Resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"Resource">>} ``` **Example 2**: creating `jid()` from namepart ```erlang > jid:make(<<"Server">>). #jid{user = <<>>,server = <<"Server">>,resource = <<>>, luser = <<>>,lserver = <<"server">>,lresource = <<>>} ``` **Example 3**: stringprep failure ```erlang > jid:make({<<"@">>, <<"server">>, <<"resource">>}). error ``` ## make/2 ```erlang -spec make(User :: binary(), Server :: binary()) -> jid() | error. ``` Shorthand for `make({User, Server, <<>>})`. ## make/3 ```erlang -spec make(User :: binary(), Server :: binary(), Resource :: binary()) -> jid() | error. ``` Same as `make({User, Server, Resource})`. ## nodeprep/1 ```erlang -spec nodeprep(binary()) -> binary() | error. ``` Applies Nodeprep Profile of Stringprep. Returns `error` on failure. **Example**: ```erlang > jid:nodeprep(<<"User">>). <<"user">> > jid:nodeprep(<<"@">>). error ``` ## nameprep/1 ```erlang -spec nameprep(binary()) -> binary() | error. ``` Applies Nameprep Profile of Stringprep. Returns `error` on failure. **Example**: ```erlang > jid:nameprep(<<"SerVer">>). <<"server">> ``` ## resourceprep/1 ```erlang -spec resourceprep(binary()) -> binary() | error. ``` Applies Resourceprep Profile of Stringprep. Returns `error` on failure. **Example**: ```erlang > jid:resourceprep(<<"Resource">>). <<"Resource">> ``` ## tolower/1 ```erlang -spec tolower(jid() | ljid()) -> ljid() | error. ``` Creates `ljid()` with Stringprep Profile applied to its parts. Returns `error` if stringprep has failed. **Example 1**: creating from `jid()` ```erlang > JID. #jid{user = <<"User">>,server = <<"Server">>, resource = <<"Resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"Resource">>} > jid:tolower(JID). {<<"user">>,<<"server">>,<<"Resource">>} ``` **Example 2**: creating from `ljid()` ```erlang > jid:tolower({<<"User">>, <<"Server">>, <<"Resource">>}). {<<"user">>,<<"server">>,<<"Resource">>} ``` **Example 3**: stringprep failure ```erlang > jid:tolower({<<"@">>, <<"Server">>, <<"Resource">>}). error ``` ## split/1 ```erlang -spec split(jid()) -> ljid(). ``` Creates `ljid()` from `jid()`. Unlike [tolower/1](#tolower1) Strinprep Profile is not applied. **Example**: ```erlang > JID. #jid{user = <<"User">>,server = <<"Server">>, resource = <<"Resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"Resource">>} > jid:split(JID). {<<"User">>,<<"Server">>,<<"Resource">>} ``` ## remove_resource/1 ```erlang -spec remove_resource(jid()) -> jid(); (ljid()) -> ljid(). ``` Removes resource part of a JID. **Example 1**: removing resource of `jid()` ```erlang > JID. #jid{user = <<"User">>,server = <<"Server">>, resource = <<"Resource">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"Resource">>} > jid:remove_resource(JID). #jid{user = <<"User">>,server = <<"Server">>, resource = <<>>,luser = <<"user">>,lserver = <<"server">>, lresource = <<>>} ``` **Example 2**: removing resource of `ljid()` ```erlang > jid:remove_resource({<<"User">>, <<"Server">>, <<"Resource">>}). {<<"User">>,<<"Server">>,<<>>} ``` ## replace_resource/2 ```erlang -spec replace_resource(jid(), binary()) -> error | jid(). ``` Replaces resource part of a JID. Returns `error` if resourceprep has failed. **Example**: replacing resource ```erlang > JID. #jid{user = <<"User">>,server = <<"Server">>, resource = <<"old">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"old">>} > jid:replace_resource(JID, <<"new">>). #jid{user = <<"User">>,server = <<"Server">>, resource = <<"new">>,luser = <<"user">>, lserver = <<"server">>,lresource = <<"new">>} ``` xmpp-1.4.4/CONTRIBUTING.md0000644000232200023220000001356513610066730015317 0ustar debalancedebalance# Contributing We'd love for you to contribute to our source code and to make our project even better than it is today! Here are the guidelines we'd like you to follow: * [Code of Conduct](#coc) * [Questions and Problems](#question) * [Issues and Bugs](#issue) * [Feature Requests](#feature) * [Issue Submission Guidelines](#submit) * [Pull Request Submission Guidelines](#submit-pr) * [Signing the CLA](#cla) ## Code of Conduct Help us keep our community open-minded and inclusive. Please read and follow our [Code of Conduct][coc]. ## Questions, Bugs, Features ### Got a Question or Problem? Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on dedicated support platforms, the best being [Stack Overflow][stackoverflow]. Stack Overflow is a much better place to ask questions since: - there are thousands of people willing to help on Stack Overflow - questions and answers stay available for public viewing so your question / answer might help someone else - Stack Overflow's voting system assures that the best answers are prominently visible. To save your and our time, we will systematically close all issues that are requests for general support and redirect people to the section you are reading right now. ### Found an Issue or Bug? If you find a bug in the source code, you can help us by submitting an issue to our [GitHub Repository][github]. Even better, you can submit a Pull Request with a fix. ### Missing a Feature? You can request a new feature by submitting an issue to our [GitHub Repository][github-issues]. If you would like to implement a new feature then consider what kind of change it is: * **Major Changes** that you wish to contribute to the project should be discussed first in an [GitHub issue][github-issues] that clearly outlines the changes and benefits of the feature. * **Small Changes** can directly be crafted and submitted to the [GitHub Repository][github] as a Pull Request. See the section about [Pull Request Submission Guidelines](#submit-pr). ## Issue Submission Guidelines Before you submit your issue search the archive, maybe your question was already answered. If your issue appears to be a bug, and hasn't been reported, open a new issue. Help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues. The "[new issue][github-new-issue]" form contains a number of prompts that you should fill out to make it easier to understand and categorize the issue. ## Pull Request Submission Guidelines By submitting a pull request for a code or doc contribution, you need to have the right to grant your contribution's copyright license to ProcessOne. Please check [ProcessOne CLA][cla] for details. Before you submit your pull request consider the following guidelines: * Search [GitHub][github-pr] for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort. * Make your changes in a new git branch: ```shell git checkout -b my-fix-branch master ``` * Test your changes and, if relevant, expand the automated test suite. * Create your patch commit, including appropriate test cases. * If the changes affect public APIs, change or add relevant documentation. * Commit your changes using a descriptive commit message. ```shell git commit -a ``` Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. * Push your branch to GitHub: ```shell git push origin my-fix-branch ``` * In GitHub, send a pull request to `master` branch. This will trigger the continuous integration and run the test. We will also notify you if you have not yet signed the [contribution agreement][cla]. * If you find that the continunous integration has failed, look into the logs to find out if your changes caused test failures, the commit message was malformed etc. If you find that the tests failed or times out for unrelated reasons, you can ping a team member so that the build can be restarted. * If we suggest changes, then: * Make the required updates. * Test your changes and test cases. * Commit your changes to your branch (e.g. `my-fix-branch`). * Push the changes to your GitHub repository (this will update your Pull Request). You can also amend the initial commits and force push them to the branch. ```shell git rebase master -i git push origin my-fix-branch -f ``` This is generally easier to follow, but separate commits are useful if the Pull Request contains iterations that might be interesting to see side-by-side. That's it! Thank you for your contribution! ## Signing the Contributor License Agreement (CLA) Upon submitting a Pull Request, we will ask you to sign our CLA if you haven't done so before. It's a quick process, we promise, and you will be able to do it all online You can read [ProcessOne Contribution License Agreement][cla] in PDF. This is part of the legal framework of the open-source ecosystem that adds some red tape, but protects both the contributor and the company / foundation behind the project. It also gives us the option to relicense the code with a more permissive license in the future. [coc]: https://github.com/processone/xmpp/blob/master/CODE_OF_CONDUCT.md [stackoverflow]: https://stackoverflow.com/ [github]: https://github.com/processone/xmpp [github-issues]: https://github.com/processone/xmpp/issues [github-new-issue]: https://github.com/processone/xmpp/issues/new [github-pr]: https://github.com/processone/xmpp/pulls [cla]: https://www.process-one.net/resources/ejabberd-cla.pdf [license]: https://github.com/processone/xmpp/blob/master/LICENSE.txt