Scroll to navigation

AnyEvent::XMPP::Ext::DataForm(3pm) User Contributed Perl Documentation AnyEvent::XMPP::Ext::DataForm(3pm)

NAME

AnyEvent::XMPP::Ext::DataForm - XEP-0004 DataForm

SYNOPSIS

DESCRIPTION

This module represents a Data Form as specified in XEP-0004.

METHODS

This method appends a field to the form. $field must have the structure as described in "FIELD STRUCTURE" below.
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).

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.

This method removes all fields that have no values and options.
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".
This method sets the type of the form, which must be one of:

   form, submit, cancel, result
    
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.
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.

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.

This method returns a list of fields. Each field has the structure as described in "FIELD STRUCTURE".
Returns the field with the unique field name $var or undef if no such field is in this form.
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.
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".
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.

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.

2019-02-18 perl v5.28.1