.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 3" .TH AnyEvent::XMPP::Ext::DataForm 3 2024-07-13 "perl v5.38.2" "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 XEP\-0004. .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 "FIELD STRUCTURE" 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 XML node and reads out the fields and all associated information. .Sp (\f(CW$node\fR must be the XML 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 "FIELD STRUCTURE", 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 "FIELD STRUCTURE"). 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 "FIELD STRUCTURE". .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. .ie n .IP "\fBset_field_value ($var, \fR\fB$value\fR\fB)\fR" 4 .el .IP "\fBset_field_value ($var, \fR\f(CB$value\fR\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. .ie n .IP "\fBadd_field_value ($var, \fR\fB$value\fR\fB)\fR" 4 .el .IP "\fBadd_field_value ($var, \fR\f(CB$value\fR\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 \&\fBNOTE:\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 XEP 0004. .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 1 \& XEP 0004 .Ve .SH AUTHOR .IX Header "AUTHOR" Robin Redeker, \f(CW\*(C`\*(C'\fR, JID: \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.