source: perl/lib/Net/Jabber/Dialback/Verify.pm @ a75309a

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since a75309a was 0ff8d110, checked in by Alejandro R. Sedeño <asedeno@mit.edu>, 18 years ago
Adding XML::Stream, Net::XMPP, and Net::Jabber to perl/lib/
  • Property mode set to 100644
File size: 7.3 KB
Line 
1##############################################################################
2#
3#  This library is free software; you can redistribute it and/or
4#  modify it under the terms of the GNU Library General Public
5#  License as published by the Free Software Foundation; either
6#  version 2 of the License, or (at your option) any later version.
7#
8#  This library is distributed in the hope that it will be useful,
9#  but WITHOUT ANY WARRANTY; without even the implied warranty of
10#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11#  Library General Public License for more details.
12#
13#  You should have received a copy of the GNU Library General Public
14#  License along with this library; if not, write to the
15#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16#  Boston, MA  02111-1307, USA.
17#
18#  Jabber
19#  Copyright (C) 1998-1999 The Jabber Team http://jabber.org/
20#
21##############################################################################
22
23package Net::Jabber::Dialback::Verify;
24
25=head1 NAME
26
27Net::Jabber::Dialback::Verify - Jabber Dialback Verify Module
28
29=head1 SYNOPSIS
30
31  Net::Jabber::Dialback::Verify is a companion to the Net::Jabber::Dialback
32  module.  It provides the user a simple interface to set and retrieve all
33  parts of a Jabber Dialback Verify.
34
35=head1 DESCRIPTION
36
37  To initialize the Verify with a Jabber <db:*/> you must pass it
38  the XML::Stream hash.  For example:
39
40    my $dialback = new Net::Jabber::Dialback::Verify(%hash);
41
42  There has been a change from the old way of handling the callbacks.
43  You no longer have to do the above yourself, a NJ::Dialback::Verify
44  object is passed to the callback function for the message.  Also,
45  the first argument to the callback functions is the session ID from
46  XML::Streams.  There are some cases where you might want this
47  information, like if you created a Client that connects to two servers
48  at once, or for writing a mini server.
49
50    use Net::Jabber qw(Server);
51
52    sub dialbackVerify {
53      my ($sid,$Verify) = @_;
54      .
55      .
56      .
57    }
58
59  You now have access to all of the retrieval functions available.
60
61  To create a new dialback to send to the server:
62
63    use Net::Jabber qw(Server);
64
65    $Verify = new Net::Jabber::Dialback::Verify();
66
67  Now you can call the creation functions below to populate the tag before
68  sending it.
69
70  For more information about the array format being passed to the CallBack
71  please read the Net::Jabber::Client documentation.
72
73=head2 Retrieval functions
74
75    $to         = $Verify->GetTo();
76    $from       = $Verify->GetFrom();
77    $type       = $Verify->GetType();
78    $id         = $Verify->GetID();
79    $data       = $Verify->GetData();
80
81    $str        = $Verify->GetXML();
82    @dialback   = $Verify->GetTree();
83
84=head2 Creation functions
85
86    $Verify->SetVerify(from=>"jabber.org",
87                       to=>"jabber.com",
88                       id=>id,
89                       data=>key);
90    $Verify->SetTo("jabber.org");
91    $Verify->SetFrom("jabber.com");
92    $Verify->SetType("valid");
93    $Verify->SetID(id);
94    $Verify->SetData(key);
95
96=head2 Test functions
97
98    $test = $Verify->DefinedTo();
99    $test = $Verify->DefinedFrom();
100    $test = $Verify->DefinedType();
101    $test = $Verify->DefinedID();
102
103=head1 METHODS
104
105=head2 Retrieval functions
106
107  GetTo() -  returns a string with server that the <db:verify/> is being
108             sent to.
109
110  GetFrom() -  returns a string with server that the <db:verify/> is being
111               sent from.
112
113  GetType() - returns a string with the type <db:verify/> this is.
114
115  GetID() - returns a string with the id <db:verify/> this is.
116
117  GetData() - returns a string with the cdata of the <db:verify/>.
118
119  GetXML() - returns the XML string that represents the <db:verify/>.
120             This is used by the Send() function in Server.pm to send
121             this object as a Jabber Dialback Verify.
122
123  GetTree() - returns an array that contains the <db:verify/> tag
124              in XML::Parser::Tree format.
125
126=head2 Creation functions
127
128  SetVerify(to=>string,   - set multiple fields in the <db:verify/>
129            from=>string,   at one time.  This is a cumulative
130            type=>string,   and over writing action.  If you set
131            id=>string,     the "from" attribute twice, the second
132            data=>string)   setting is what is used.  If you set
133                            the type, and then set the data
134                            then both will be in the <db:verify/>
135                            tag.  For valid settings read the
136                            specific Set functions below.
137
138  SetTo(string) - sets the to attribute.
139
140  SetFrom(string) - sets the from attribute.
141
142  SetType(string) - sets the type attribute.  Valid settings are:
143
144                    valid
145                    invalid
146
147  SetID(string) - sets the id attribute.
148
149  SetData(string) - sets the cdata of the <db:verify/>.
150
151=head2 Test functions
152
153  DefinedTo() - returns 1 if the to attribute is defined in the
154                <db:verify/>, 0 otherwise.
155
156  DefinedFrom() - returns 1 if the from attribute is defined in the
157                  <db:verify/>, 0 otherwise.
158
159  DefinedType() - returns 1 if the type attribute is defined in the
160                  <db:verify/>, 0 otherwise.
161
162  DefinedID() - returns 1 if the id attribute is defined in the
163                  <db:verify/>, 0 otherwise.
164
165=head1 AUTHOR
166
167By Ryan Eatmon in May of 2001 for http://jabber.org..
168
169=head1 COPYRIGHT
170
171This module is free software; you can redistribute it and/or modify
172it under the same terms as Perl itself.
173
174=cut
175
176require 5.003;
177use strict;
178use Carp;
179use vars qw($VERSION $AUTOLOAD %FUNCTIONS);
180
181$VERSION = "2.0";
182
183sub new
184{
185    my $proto = shift;
186    my $class = ref($proto) || $proto;
187    my $self = { };
188
189    $self->{VERSION} = $VERSION;
190
191    bless($self, $proto);
192
193    $self->{DEBUGHEADER} = "DB:Verify";
194
195    $self->{DATA} = {};
196    $self->{CHILDREN} = {};
197
198    $self->{TAG} = "db:verify";
199
200    if ("@_" ne (""))
201    {
202        if (ref($_[0]) eq "Net::Jabber::Dialback::Verify")
203        {
204            return $_[0];
205        }
206        else
207        {
208            $self->{TREE} = shift;
209            $self->ParseTree();
210        }
211    }
212
213    return $self;
214}
215
216
217##############################################################################
218#
219# AUTOLOAD - This function calls the main AutoLoad function in Jabber.pm
220#
221##############################################################################
222sub AUTOLOAD
223{
224    my $self = shift;
225    &Net::Jabber::AutoLoad($self,$AUTOLOAD,@_);
226}
227
228$FUNCTIONS{From}->{Get}        = "from";
229$FUNCTIONS{From}->{Set}        = ["jid","from"];
230$FUNCTIONS{From}->{Defined}    = "from";
231$FUNCTIONS{From}->{Hash}       = "att";
232
233$FUNCTIONS{Data}->{Get}        = "data";
234$FUNCTIONS{Data}->{Set}        = ["scalar","data"];
235$FUNCTIONS{Data}->{Defined}    = "data";
236$FUNCTIONS{Data}->{Hash}       = "data";
237
238$FUNCTIONS{ID}->{Get}        = "id";
239$FUNCTIONS{ID}->{Set}        = ["scalar","id"];
240$FUNCTIONS{ID}->{Defined}    = "id";
241$FUNCTIONS{ID}->{Hash}       = "child-data";
242
243$FUNCTIONS{To}->{Get}        = "to";
244$FUNCTIONS{To}->{Set}        = ["jid","to"];
245$FUNCTIONS{To}->{Defined}    = "to";
246$FUNCTIONS{To}->{Hash}       = "att";
247
248$FUNCTIONS{Type}->{Get}        = "type";
249$FUNCTIONS{Type}->{Set}        = ["scalar","type"];
250$FUNCTIONS{Type}->{Defined}    = "type";
251$FUNCTIONS{Type}->{Hash}       = "att";
252
253$FUNCTIONS{Verify}->{Get} = "__netjabber__:master";
254$FUNCTIONS{Verify}->{Set} = ["master"];
255
2561;
Note: See TracBrowser for help on using the repository browser.