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 | |
---|
23 | package Net::Jabber::Dialback; |
---|
24 | |
---|
25 | =head1 NAME |
---|
26 | |
---|
27 | Net::Jabber::Dialback - Jabber Dialback Module |
---|
28 | |
---|
29 | =head1 SYNOPSIS |
---|
30 | |
---|
31 | Net::Jabber::Dialback is a companion to the Net::Jabber::Server |
---|
32 | module. It provides the user a simple interface to set and retrieve |
---|
33 | all parts of a Jabber Server Dialback. |
---|
34 | |
---|
35 | =head1 DESCRIPTION |
---|
36 | |
---|
37 | To initialize the Dialback with a Jabber <db:*/> you must pass it |
---|
38 | the XML::Stream hash. For example: |
---|
39 | |
---|
40 | my $dialback = Net::Jabber::Dialback->new(%hash); |
---|
41 | |
---|
42 | You now have access to all of the retrieval functions available. |
---|
43 | |
---|
44 | To create a new message to send to the server: |
---|
45 | |
---|
46 | use Net::Jabber qw(Server); |
---|
47 | |
---|
48 | $DB = Net::Jabber::Dialback->new("verify"); |
---|
49 | $DB = Net::Jabber::Dialback->new("result"); |
---|
50 | |
---|
51 | Please see the specific documentation for Net::Jabber::Dialback::Result |
---|
52 | and Net::Jabber::Dialback::Verify. |
---|
53 | |
---|
54 | For more information about the array format being passed to the |
---|
55 | CallBack please read the Net::Jabber::Client documentation. |
---|
56 | |
---|
57 | =head1 AUTHOR |
---|
58 | |
---|
59 | By Ryan Eatmon in May of 2001 for http://jabber.org.. |
---|
60 | |
---|
61 | =head1 COPYRIGHT |
---|
62 | |
---|
63 | This module is free software; you can redistribute it and/or modify |
---|
64 | it under the same terms as Perl itself. |
---|
65 | |
---|
66 | =cut |
---|
67 | |
---|
68 | require 5.003; |
---|
69 | use strict; |
---|
70 | use Carp; |
---|
71 | use vars qw($VERSION $AUTOLOAD %FUNCTIONS); |
---|
72 | |
---|
73 | $VERSION = "2.0"; |
---|
74 | |
---|
75 | use Net::Jabber::Dialback::Result; |
---|
76 | ($Net::Jabber::Dialback::Result::VERSION < $VERSION) && |
---|
77 | die("Net::Jabber::Dialback::Result $VERSION required--this is only version $Net::Jabber::Dialback::Result::VERSION"); |
---|
78 | |
---|
79 | use Net::Jabber::Dialback::Verify; |
---|
80 | ($Net::Jabber::Dialback::Verify::VERSION < $VERSION) && |
---|
81 | die("Net::Jabber::Dialback::Verify $VERSION required--this is only version $Net::Jabber::Dialback::Verify::VERSION"); |
---|
82 | |
---|
83 | sub new |
---|
84 | { |
---|
85 | my $proto = shift; |
---|
86 | my $class = ref($proto) || $proto; |
---|
87 | my $self = { }; |
---|
88 | |
---|
89 | bless($self, $proto); |
---|
90 | |
---|
91 | if ("@_" ne ("")) |
---|
92 | { |
---|
93 | if (ref($_[0]) =~ /Net::Jabber::Dialback/) |
---|
94 | { |
---|
95 | return $_[0]; |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | my ($temp) = @_; |
---|
100 | return Net::Jabber::Dialback::Result->new() |
---|
101 | if ($temp eq "result"); |
---|
102 | return Net::Jabber::Dialback::Verify->new() |
---|
103 | if ($temp eq "verify"); |
---|
104 | |
---|
105 | my @temp = @{$temp}; |
---|
106 | return Net::Jabber::Dialback::Result->new(@temp) |
---|
107 | if ($temp[0] eq "db:result"); |
---|
108 | return Net::Jabber::Dialback::Verify->new(@temp) |
---|
109 | if ($temp[0] eq "db:verify"); |
---|
110 | } |
---|
111 | } |
---|
112 | else |
---|
113 | { |
---|
114 | carp "You must specify either \"result\" or \"verify\" as an argument"; |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | 1; |
---|