ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-XMPP2/lib/Net/XMPP2/Ext/RegisterForm.pm
Revision: 1.1
Committed: Tue Apr 24 17:37:21 2007 UTC (19 years, 5 months ago) by elmex
Branch: MAIN
Log Message:
fixed a minor bug in binding error handling and further work
on the in-band-registration stuff

File Contents

# User Rev Content
1 elmex 1.1 package Net::XMPP2::RegisterForm;
2     use strict;
3     use Net::XMPP2::Util;
4     use Net::XMPP2::Namespaces qw/xmpp_ns/;
5    
6     =head1 NAME
7    
8     Net::XMPP2::RegisterForm - A handle for in band registration
9    
10     =head1 SYNOPSIS
11    
12     my $con = Net::XMPP2::Connection->new (...);
13     ...
14     $con->do_in_band_register (sub {
15     my ($form, $error) = @_;
16     if ($error) { print "ERROR: ".$error->string."\n" }
17     else {
18     if ($form->type eq 'simple') {
19     if ($form->has_field ('username') && $form->has_field ('password')) {
20     $form->set_field (
21     username => 'test',
22     password => 'qwerty',
23     );
24     $form->submit (sub {
25     my ($form, $error) = @_;
26     if ($error) { print "SUBMIT ERROR: ".$error->string."\n" }
27     else {
28     print "Successfully registered as ".$form->field ('username')."\n"
29     }
30     });
31     } else {
32     print "Couldn't fill out the form: " . $form->field ('instructions') ."\n";
33     }
34     } elsif ($form->type eq 'data_form' {
35     my $dform = $form->data_form;
36     ... fill out the form $dform (of type Net::XMPP2::DataForm) ...
37     $form->submit_data_form ($dform, sub {
38     my ($form, $error) = @_;
39     if ($error) { print "DATA FORM SUBMIT ERROR: ".$error->string."\n" }
40     else {
41     print "Successfully registered as ".$form->field ('username')."\n"
42     }
43     })
44     }
45     }
46     });
47    
48     =head1 DESCRIPTION
49    
50     This module represents an in band registration form
51     which can be filled out and submitted.
52    
53     You can get an instance of this class only by requesting it
54     from a L<Net::XMPP2::Connection> by calling the C<request_inband_register_form>
55     method.
56    
57     =cut
58    
59     sub new {
60     my $this = shift;
61     my $class = ref($this) || $this;
62     my $self = bless { @_ }, $class;
63     $self->init
64     $self
65     }
66    
67     sub init {
68     my ($self) = @_;
69     my $node = $self->{node};
70    
71     # TODO
72     }
73    
74     =head1 AUTHOR
75    
76     Robin Redeker, C<< <elmex at ta-sa.org> >>
77    
78     =head1 COPYRIGHT & LICENSE
79    
80     Copyright 2007 Robin Redeker, all rights reserved.
81    
82     This program is free software; you can redistribute it and/or modify it
83     under the same terms as Perl itself.
84    
85     =cut
86    
87     1; # End of Net::XMPP2::RegisterForm