Provided by: libanyevent-xmpp-perl_0.55-4_all
NAME
AnyEvent::XMPP::Ext::DataForm - XEP-0004 DataForm
SYNOPSIS
DESCRIPTION
This module represents a Data Form as specified in XEP-0004.
METHODS
new (%args) append_field ($field) This method appends a field to the form. $field must have the structure as described in "FIELD STRUCTURE" below. from_node ($node) This method interprets the AnyEvent::XMPP::Node object in $node as data form XML node and reads out the fields and all associated information. ($node must be the XML node of the <x xmlns='jabber:x:data'> tag). make_answer_form ($request_form) This method initializes this form with default answers and other neccessary fields from $request_form, which must be of type AnyEvent::XMPP::Ext::DataForm or compatible. The result will be a form with a copy of all fields which are not of type "fixed". The fields will also have the default value copied over. The form type will be set to "submit". The idea is: this creates a template answer form from $request_form. To strip out the unneccessary fields later you don't need call the "clear_empty_fields" method. clear_empty_fields This method removes all fields that have no values and options. remove_field ($field_or_var) This method removes a field either by it's unique name or by reference. $field_or_var can either be the unique name or the actual field hash reference you get from "get_field" or "get_fields". set_form_type ($type) This method sets the type of the form, which must be one of: form, submit, cancel, result form_type This method returns the type of the form, which is one of the options described in "set_form_type" above or undef if no type was yet set. get_reported_fields If this is a search result this method returns more than one element here. The returned list consists of fields as described in "FIELD STRUCTURE", only that they lack values and options. See also the "get_items" method. get_items If this form is a search result this method returns the list of items of that search. An item is a array ref of fields (field structure is described in "FIELD STRUCTURE"). This method returns a list of items. get_fields This method returns a list of fields. Each field has the structure as described in "FIELD STRUCTURE". get_field ($var) Returns the field with the unique field name $var or undef if no such field is in this form. set_field_value ($var, $value) This method sets the value of the field with the unique name $var. If the field has supports multiple values all values will be removed and only $value will be added, if $value is undefined the field's value will be deleted. add_field_value ($var, $value) This method adds the $value to the field with the unique name $var. If the field doesn't support multiple values this method has the same effect as "set_field_value". to_simxml This method converts the form to a data strcuture that you can pass as "node" argument to the "simxml" function which is documented in AnyEvent::XMPP::Util. Example call might be: my $node = $form->to_simxml; simxml ($w, defns => $node->{ns}, node => $node); NOTE: The returned simxml node has the "dns" field set so that no prefixes are generated for the namespace it is in. as_debug_string This method returns a string that represents the form. Only for debugging purposes.
FIELD STRUCTURE
{ label => 'field label', type => 'field type', var => '(unique) field name' required => true or false value, values => [ 'value text', ... ], options => [ ['option label', 'option text'], ... ] } For the semantics of all fields please consult XEP 0004.
SEE ALSO
XEP 0004
AUTHOR
Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>"
COPYRIGHT & LICENSE
Copyright 2007, 2008 Robin Redeker, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.