Module exmpp_stanza

The module exmpp_stanza provides helpers to manipulate standard stanza.

Authors: Mickael Remond (mickael.remond@process-one.net), Jean-Sébastien Pédron (js.pedron@meetic-corp.com).

Description

The module exmpp_stanza provides helpers to manipulate standard stanza.

Function Index

error/2Create an <error/> element based on the given Condition.
error/3Create an <error/> element based on the given Condition.
get_condition/1Return the child element name corresponding to the stanza error condition.
get_error/1Return the error element from Stanza.
get_error_type/1Return the type of the error element.
get_id/1Return the stanza ID.
get_id_from_attrs/1Return the stanza ID.
get_lang/1Return the language of the stanza.
get_lang_from_attrs/1Return the language of the stanza.
get_recipient/1Return the recipient.
get_recipient_from_attrs/1Return the recipient.
get_sender/1Return the sender.
get_sender_from_attrs/1Return the sender.
get_text/1Return the text that describes the error.
get_type/1Return the type of the stanza.
get_type_from_attrs/1Return the type of the stanza.
is_stanza_error/1Tell if the stanza transports an error.
remove_recipient/1Remove the recipient.
remove_recipient_in_attrs/1Remove the recipient.
remove_sender/1Remove the sender.
remove_sender_in_attrs/1Remove the sender.
reply/1Prepare a reply to Stanza.
reply_from_attrs/1Handles to and from attributes to prepare a reply stanza.
reply_with_error/2Prepare an error reply to Stanza.
reply_without_content/1Prepare a reply to Stanza with children removed.
set_error_type/2Set the type of the error element.
set_error_type_from_condition/2Set the type of the error element, based on the given condition.
set_id/2Set the ID.
set_id_in_attrs/2Set the ID.
set_jids/3Set the sender and the recipient at the same time.
set_jids_in_attrs/3Set the sender and the recipient at the same time.
set_lang/2Set the lang.
set_lang_in_attrs/2Set the lang.
set_recipient/2Set the recipient.
set_recipient_in_attrs/2Set the recipient.
set_sender/2Set the sender.
set_sender_in_attrs/2Set the sender.
set_type/2Set the type of the stanza.
set_type_in_attrs/2Set the type of the stanza.
stanza_error/2Transform Stanza in a stanza error.
stanza_error_without_original/2Transform Stanza in a stanza error.
to_binary/1Serialize a stanza using common XMPP default namespaces.
to_binary/2Serialize a stanza using the given default namespace.
to_binary/3Serialize a stanza using the given namespaces.
to_iolist/1Serialize a stanza using common XMPP default namespaces.
to_iolist/2Serialize a stanza using the given default namespace.
to_iolist/3Serialize a stanza using the given namespaces.
to_list/1Serialize a stanza using common XMPP default namespaces.
to_list/2Serialize a stanza using the given default namespace.
to_list/3Serialize a stanza using the given namespaces.

Function Details

error/2

error(NS, Condition) -> Stanza_Error

Create an <error/> element based on the given Condition.

A default type is set by set_error_type/2 if NS is jabber:client or jabber:server. This does not contain any text element.

error/3

error(NS, Condition, Text::Text_Spec) -> Stanza_Error

Create an <error/> element based on the given Condition.

A default type is set by set_error_type/2 if NS is jabber:client or jabber:server. This does not contain any text element.

get_condition/1

get_condition(Stanza) -> Condition | undefined

throws {stanza_error, condition, no_error_element_found, Stanza} | {stanza_error, condition, no_condition_found, Error}

Return the child element name corresponding to the stanza error condition.

If the namespace isn't neither jabber:client nor jabber:server, the name of the first child is returned.

get_error/1

get_error(Xmlel::Stanza) -> Error | undefined

Return the error element from Stanza.

The error element is supposed to have the name error and the same namespace as the stanza.

get_error_type/1

get_error_type(Stanza) -> Type

throws {stanza_error, error_type, no_error_element_found, Stanza}

Return the type of the error element.

get_id/1

get_id(Xmlel::Stanza) -> ID | undefined

Return the stanza ID.

get_id_from_attrs/1

get_id_from_attrs(Attrs) -> ID | undefined

Return the stanza ID.

get_lang/1

get_lang(Xmlel::Stanza) -> Lang | undefined

Return the language of the stanza.

get_lang_from_attrs/1

get_lang_from_attrs(Attrs) -> Lang | undefined

Return the language of the stanza.

get_recipient/1

get_recipient(Xmlel::Stanza) -> Recipient | undefined

Return the recipient.

The return value should be a JID and may be parsed with exmpp_jid:parse/1.

get_recipient_from_attrs/1

get_recipient_from_attrs(Attrs) -> Recipient | undefined

Return the recipient.

The return value should be a JID and may be parsed with exmpp_jid:parse/1.

get_sender/1

get_sender(Xmlel::Stanza) -> Sender | undefined

Return the sender.

The return value should be a JID and may be parsed with exmpp_jid:parse/1.

get_sender_from_attrs/1

get_sender_from_attrs(Attrs) -> Sender | undefined

Return the sender.

The return value should be a JID and may be parsed with exmpp_jid:parse/1.

get_text/1

get_text(Stanza) -> Text | undefined

throws {stanza_error, text, no_error_element_found, Stanza}

Return the text that describes the error.

If there is no <text/> element, an empty string is returned.

get_type/1

get_type(Xmlel::Stanza) -> Type | undefined

Return the type of the stanza.

get_type_from_attrs/1

get_type_from_attrs(Attrs) -> Type | undefined

Return the type of the stanza.

is_stanza_error/1

is_stanza_error(Stanza) -> bool()

Tell if the stanza transports an error.

remove_recipient/1

remove_recipient(Xmlel::Stanza) -> New_Stanza

Remove the recipient.

remove_recipient_in_attrs/1

remove_recipient_in_attrs(Attrs) -> New_Attrs

Remove the recipient.

remove_sender/1

remove_sender(Xmlel::Stanza) -> New_Stanza

Remove the sender.

remove_sender_in_attrs/1

remove_sender_in_attrs(Attrs) -> New_Attrs

Remove the sender.

reply/1

reply(Xmlel::Stanza) -> Stanza_Reply

Prepare a reply to Stanza.

See also: reply_from_attrs/1.

reply_from_attrs/1

reply_from_attrs(Attrs) -> New_Attrs

Handles to and from attributes to prepare a reply stanza.

reply_with_error/2

reply_with_error(Stanza, Condition::Error) -> Stanza_Reply

Prepare an error reply to Stanza.

If Error is an atom, it must be a standard condition defined by XMPP Core.

reply_without_content/1

reply_without_content(Xmlel::Stanza) -> Stanza_Reply

Prepare a reply to Stanza with children removed.

See also: reply_from_attrs/1.

set_error_type/2

set_error_type(Stanza, Type) -> New_Stanza

throws {stanza_error, error_type, no_error_element_found, Stanza}

Set the type of the error element.

set_error_type_from_condition/2

set_error_type_from_condition(Stanza, Condition) -> New_Stanza

throws {stanza_error, error_type, no_error_element_found, Stanza} | {stanza_error, error_type, invalid_condition, {NS, Condition}}

Set the type of the error element, based on the given condition.

If the condition is undefined-condition, the type is unchanged.

set_id/2

set_id(Xmlel::Stanza, ID) -> New_Stanza

Set the ID.

If ID is undefined or empty, it's removed. If ID is random, a random value is set.

set_id_in_attrs/2

set_id_in_attrs(Attrs, ID) -> New_Attrs

Set the ID.

If ID is undefined or empty, it's removed. If ID is random, a random value is set.

set_jids/3

set_jids(Stanza, From::Sender, To::Recipient) -> New_Stanza

Set the sender and the recipient at the same time.

If Sender is set to undefined, the sender is removed. If Recipient is set to undefined, the recipient is removed.

set_jids_in_attrs/3

set_jids_in_attrs(Attrs, From::Sender, To::Recipient) -> New_Attrs

Set the sender and the recipient at the same time.

If Sender is set to undefined, the sender is removed. If Recipient is set to undefined, the recipient is removed.

set_lang/2

set_lang(Xmlel::Stanza, Lang) -> New_Stanza

Set the lang.

If Lang is undefined or empty, it's removed.

set_lang_in_attrs/2

set_lang_in_attrs(Attrs, Lang) -> New_Attrs

Set the lang.

If Lang is undefined or empty, it's removed.

set_recipient/2

set_recipient(Xmlel::Stanza, Recipient) -> New_Stanza

Set the recipient.

If Recipient is set to undefined, the recipient is removed.

set_recipient_in_attrs/2

set_recipient_in_attrs(Attrs, Recipient) -> New_Attrs

Set the recipient.

If Recipient is set to undefined, the recipient is removed.

set_sender/2

set_sender(Xmlel::Stanza, Sender) -> New_Stanza

Set the sender.

If Sender is set to undefined, the sender is removed.

set_sender_in_attrs/2

set_sender_in_attrs(Attrs, Sender) -> New_Attrs

Set the sender.

If Sender is set to undefined, the sender is removed.

set_type/2

set_type(Xmlel::Stanza, Type) -> New_Stanza

Set the type of the stanza.

set_type_in_attrs/2

set_type_in_attrs(Attrs, Type) -> New_Attrs

Set the type of the stanza.

stanza_error/2

stanza_error(Stanza, Error) -> Stanza_Error

Transform Stanza in a stanza error.

The type attribute is set and an error condition is added. The caller is still responsible to set or modify the to attribute correctly.

See also: error/2, error/3.

stanza_error_without_original/2

stanza_error_without_original(Stanza, Error) -> Stanza_Error

Transform Stanza in a stanza error.

Previous child elements from Stanza are not kept.

See also: stanza_error/2.

to_binary/1

to_binary(El) -> XML_Text

Serialize a stanza using common XMPP default namespaces.

This function calls to_binary/2 with Default_NS set to [?NS_JABBER_CLIENT, ?NS_JABBER_SERVER, ?NS_COMPONENT_ACCEPT, ?NS_COMPONENT_CONNECT].

to_binary/2

to_binary(El, Default_NS) -> XML_Text

Serialize a stanza using the given default namespace.

The XMPP namespace http://etherx.jabber.org/streams and the Server Dialback jabber:server:dialback are included as a prefixed namespace, with the stream prefix.

to_binary/3

to_binary(Iq::El, Default_NS, Prefixed_NS::Prefix) -> XML_Text

Serialize a stanza using the given namespaces.

To understand Default_NS, see exmpp_xml:xmlel_to_xmlelement/3.

to_iolist/1

to_iolist(El) -> XML_Text

Serialize a stanza using common XMPP default namespaces.

This function calls to_iolist/2 with Default_NS set to [?NS_JABBER_CLIENT, ?NS_JABBER_SERVER, ?NS_COMPONENT_ACCEPT, ?NS_COMPONENT_CONNECT].

to_iolist/2

to_iolist(El, Default_NS) -> XML_Text

Serialize a stanza using the given default namespace.

The XMPP namespace http://etherx.jabber.org/streams and the Server Dialback jabber:server:dialback are included as a prefixed namespace, with the stream prefix.

to_iolist/3

to_iolist(Iq::El, Default_NS, Prefixed_NS::Prefix) -> XML_Text

Serialize a stanza using the given namespaces.

To understand Default_NS, see exmpp_xml:xmlel_to_xmlelement/3.

to_list/1

to_list(El) -> XML_Text

Serialize a stanza using common XMPP default namespaces.

This function calls to_list/2 with Default_NS set to [?NS_JABBER_CLIENT, ?NS_JABBER_SERVER, ?NS_COMPONENT_ACCEPT, ?NS_COMPONENT_CONNECT].

to_list/2

to_list(El, Default_NS) -> XML_Text

Serialize a stanza using the given default namespace.

The XMPP namespace http://etherx.jabber.org/streams and the Server Dialback jabber:server:dialback are included as a prefixed namespace, with the stream prefix.

to_list/3

to_list(Iq::El, Default_NS, Prefixed_NS::Prefix) -> XML_Text

Serialize a stanza using the given namespaces.

To understand Default_NS, see exmpp_xml:xmlel_to_xmlelement/3.


Generated by EDoc, Jan 21 2011, 01:43:52.