.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" 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 turned on, 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "AnyEvent::XMPP::Ext::DataForm 3pm" .TH AnyEvent::XMPP::Ext::DataForm 3pm "2012-12-25" "perl v5.18.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 \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. .ie n .IP "\fBset_field_value ($var, \fB$value\fB)\fR" 4 .el .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. .ie n .IP "\fBadd_field_value ($var, \fB$value\fB)\fR" 4 .el .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.