.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "AnyEvent::XMPP::Ext::DataForm 3pm" .TH AnyEvent::XMPP::Ext::DataForm 3pm "2022-12-06" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" AnyEvent::XMPP::Ext::DataForm \- XEP\-0004 DataForm .SH "SYNOPSIS" .IX Header "SYNOPSIS" .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module represents a Data Form as specified in \s-1XEP\-0004.\s0 .SH "METHODS" .IX Header "METHODS" .IP "\fBnew (%args)\fR" 4 .IX Item "new (%args)" .PD 0 .IP "\fBappend_field ($field)\fR" 4 .IX Item "append_field ($field)" .PD This method appends a field to the form. \&\f(CW$field\fR must have the structure as described in \*(L"\s-1FIELD STRUCTURE\*(R"\s0 below. .IP "\fBfrom_node ($node)\fR" 4 .IX Item "from_node ($node)" This method interprets the AnyEvent::XMPP::Node object in \f(CW$node\fR as data form \s-1XML\s0 node and reads out the fields and all associated information. .Sp (\f(CW$node\fR must be the \s-1XML\s0 node of the tag). .IP "\fBmake_answer_form ($request_form)\fR" 4 .IX Item "make_answer_form ($request_form)" This method initializes this form with default answers and other neccessary fields from \f(CW$request_form\fR, which must be of type AnyEvent::XMPP::Ext::DataForm or compatible. .Sp The result will be a form with a copy of all fields which are not of type \f(CW\*(C`fixed\*(C'\fR. The fields will also have the default value copied over. .Sp The form type will be set to \f(CW\*(C`submit\*(C'\fR. .Sp The idea is: this creates a template answer form from \f(CW$request_form\fR. .Sp To strip out the unneccessary fields later you don't need call the \&\f(CW\*(C`clear_empty_fields\*(C'\fR method. .IP "\fBclear_empty_fields\fR" 4 .IX Item "clear_empty_fields" This method removes all fields that have no values and options. .IP "\fBremove_field ($field_or_var)\fR" 4 .IX Item "remove_field ($field_or_var)" This method removes a field either by it's unique name or by reference. \f(CW$field_or_var\fR can either be the unique name or the actual field hash reference you get from \f(CW\*(C`get_field\*(C'\fR or \f(CW\*(C`get_fields\*(C'\fR. .IP "\fBset_form_type ($type)\fR" 4 .IX Item "set_form_type ($type)" This method sets the type of the form, which must be one of: .Sp .Vb 1 \& form, submit, cancel, result .Ve .IP "\fBform_type\fR" 4 .IX Item "form_type" This method returns the type of the form, which is one of the options described in \f(CW\*(C`set_form_type\*(C'\fR above or undef if no type was yet set. .IP "\fBget_reported_fields\fR" 4 .IX Item "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 \*(L"\s-1FIELD STRUCTURE\*(R"\s0, only that they lack values and options. .Sp See also the \f(CW\*(C`get_items\*(C'\fR method. .IP "\fBget_items\fR" 4 .IX Item "get_items" If this form is a search result this method returns the list of items of that search. .Sp An item is a array ref of fields (field structure is described in \*(L"\s-1FIELD STRUCTURE\*(R"\s0). This method returns a list of items. .IP "\fBget_fields\fR" 4 .IX Item "get_fields" This method returns a list of fields. Each field has the structure as described in \*(L"\s-1FIELD STRUCTURE\*(R"\s0. .IP "\fBget_field ($var)\fR" 4 .IX Item "get_field ($var)" Returns the field with the unique field name \f(CW$var\fR or undef if no such field is in this form. .IP "\fBset_field_value ($var, \f(CB$value\fB)\fR" 4 .IX Item "set_field_value ($var, $value)" This method sets the value of the field with the unique name \f(CW$var\fR. If the field has supports multiple values all values will be removed and only \f(CW$value\fR will be added, if \f(CW$value\fR is undefined the field's value will be deleted. .IP "\fBadd_field_value ($var, \f(CB$value\fB)\fR" 4 .IX Item "add_field_value ($var, $value)" This method adds the \f(CW$value\fR to the field with the unique name \f(CW$var\fR. If the field doesn't support multiple values this method has the same effect as \f(CW\*(C`set_field_value\*(C'\fR. .IP "\fBto_simxml\fR" 4 .IX Item "to_simxml" This method converts the form to a data strcuture that you can pass as \f(CW\*(C`node\*(C'\fR argument to the \f(CW\*(C`simxml\*(C'\fR function which is documented in AnyEvent::XMPP::Util. .Sp Example call might be: .Sp .Vb 2 \& my $node = $form\->to_simxml; \& simxml ($w, defns => $node\->{ns}, node => $node); .Ve .Sp \&\fB\s-1NOTE:\s0\fR The returned simxml node has the \f(CW\*(C`dns\*(C'\fR field set so that no prefixes are generated for the namespace it is in. .IP "\fBas_debug_string\fR" 4 .IX Item "as_debug_string" This method returns a string that represents the form. Only for debugging purposes. .SH "FIELD STRUCTURE" .IX Header "FIELD STRUCTURE" .Vb 10 \& { \& label => \*(Aqfield label\*(Aq, \& type => \*(Aqfield type\*(Aq, \& var => \*(Aq(unique) field name\*(Aq \& required => true or false value, \& values => [ \& \*(Aqvalue text\*(Aq, \& ... \& ], \& options => [ \& [\*(Aqoption label\*(Aq, \*(Aqoption text\*(Aq], \& ... \& ] \& } .Ve .PP For the semantics of all fields please consult \s-1XEP 0004.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 1 \& XEP 0004 .Ve .SH "AUTHOR" .IX Header "AUTHOR" Robin Redeker, \f(CW\*(C`\*(C'\fR, \s-1JID:\s0 \f(CW\*(C`\*(C'\fR .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2007, 2008 Robin Redeker, all rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.