line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
|
|
|
|
# Copyright (C) 1998-2004 Jabber Software Foundation http://jabber.org/ |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################### |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Net::Jabber; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Net::Jabber - Jabber Perl Library |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Net::Jabber provides a Perl user with access to the Jabber Instant |
31
|
|
|
|
|
|
|
Messaging protocol. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
For more information about Jabber visit: |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
http://www.jabber.org |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Net::Jabber is a convenient tool to use for any perl script that would |
40
|
|
|
|
|
|
|
like to utilize the Jabber Instant Messaging protocol. While not a |
41
|
|
|
|
|
|
|
client in and of itself, it provides all of the necessary back-end |
42
|
|
|
|
|
|
|
functions to make a CGI client or command-line perl client feasible and |
43
|
|
|
|
|
|
|
easy to use. Net::Jabber is a wrapper around the rest of the official |
44
|
|
|
|
|
|
|
Net::Jabber::xxxxxx packages. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
There is are example scripts in the example directory that provide you |
47
|
|
|
|
|
|
|
with examples of very simple Jabber programs. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
NOTE: The parser that XML::Stream::Parser provides, as are most Perl |
51
|
|
|
|
|
|
|
parsers, is synchronous. If you are in the middle of parsing a packet |
52
|
|
|
|
|
|
|
and call a user defined callback, the Parser is blocked until your |
53
|
|
|
|
|
|
|
callback finishes. This means you cannot be operating on a packet, |
54
|
|
|
|
|
|
|
send out another packet and wait for a response to that packet. It |
55
|
|
|
|
|
|
|
will never get to you. Threading might solve this, but as of the |
56
|
|
|
|
|
|
|
writing of this, threading in Perl is not quite up to par yet. This |
57
|
|
|
|
|
|
|
issue will be revisted in the future. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 EXAMPLES |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
For a client: |
62
|
|
|
|
|
|
|
use Net::Jabber; |
63
|
|
|
|
|
|
|
my $client = new Net::Jabber::Client(); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
For a component: |
66
|
|
|
|
|
|
|
use Net::Jabber; |
67
|
|
|
|
|
|
|
my $component = new Net::Jabber::Component(); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The Net::Jabber module does not define any methods that you will call |
72
|
|
|
|
|
|
|
directly in your code. Instead you will instantiate objects that call |
73
|
|
|
|
|
|
|
functions from this module to do work. The three main objects that |
74
|
|
|
|
|
|
|
you will work with are the Message, Presence, and IQ modules. Each one |
75
|
|
|
|
|
|
|
corresponds to the Jabber equivilant and allows you get and set all |
76
|
|
|
|
|
|
|
parts of those packets. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 PACKAGES |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
For more information on each of these packages, please see the man page |
81
|
|
|
|
|
|
|
for each one. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 Net::Jabber::Client |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This package contains the code needed to communicate with a Jabber |
86
|
|
|
|
|
|
|
server: login, wait for messages, send messages, and logout. It uses |
87
|
|
|
|
|
|
|
XML::Stream to read the stream from the server and based on what kind |
88
|
|
|
|
|
|
|
of tag it encounters it calls a function to handle the tag. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 Net::Jabber::Component |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This package contains the code needed to write a server component. A |
93
|
|
|
|
|
|
|
component is a program tha handles the communication between a jabber |
94
|
|
|
|
|
|
|
server and some outside program or communications pacakge (IRC, talk, |
95
|
|
|
|
|
|
|
email, etc...) With this module you can write a full component in just |
96
|
|
|
|
|
|
|
a few lines of Perl. It uses XML::Stream to communicate with its host |
97
|
|
|
|
|
|
|
server and based on what kind of tag it encounters it calls a function |
98
|
|
|
|
|
|
|
to handle the tag. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 Net::Jabber::Protocol |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
A collection of high-level functions that Client and Component use to |
103
|
|
|
|
|
|
|
make their lives easier through inheritance. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 Net::Jabber::JID |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The Jabber IDs consist of three parts: user id, server, and resource. |
108
|
|
|
|
|
|
|
This module gives you access to those components without having to |
109
|
|
|
|
|
|
|
parse the string yourself. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 Net::Jabber::Message |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Everything needed to create and read a received from the |
114
|
|
|
|
|
|
|
server. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 Net::Jabber::Presence |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Everything needed to create and read a received from the |
119
|
|
|
|
|
|
|
server. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 Net::Jabber::IQ |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
IQ is a wrapper around a number of modules that provide support for the |
124
|
|
|
|
|
|
|
various Info/Query namespaces that Jabber recognizes. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 Net::Jabber::Stanza |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This module represents a namespaced stanza that is used to extend a |
129
|
|
|
|
|
|
|
, , and . Ultimately each namespace is |
130
|
|
|
|
|
|
|
documented in a JEP of some kind. http://jabber.org/jeps/ |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The man page for Net::Jabber::Stanza contains a listing of all |
133
|
|
|
|
|
|
|
supported namespaces, and the methods that are supported by the objects |
134
|
|
|
|
|
|
|
that represent those namespaces. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 Net::Jabber::Namespaces |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Jabber allows for any stanza to be extended by any bit of XML. This |
139
|
|
|
|
|
|
|
module contains all of the internals for defining the Jabber based |
140
|
|
|
|
|
|
|
extensions defined by the JEPs. The documentation for this module |
141
|
|
|
|
|
|
|
explains more about how to add your own custom namespace and have it be |
142
|
|
|
|
|
|
|
supported. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Ryan Eatmon |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This module is free software, you can redistribute it and/or modify |
151
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
require 5.005; |
156
|
49
|
|
|
49
|
|
859658
|
use strict; |
|
49
|
|
|
|
|
128
|
|
|
49
|
|
|
|
|
2216
|
|
157
|
49
|
|
|
49
|
|
383
|
use Carp; |
|
49
|
|
|
|
|
124
|
|
|
49
|
|
|
|
|
6941
|
|
158
|
49
|
|
|
49
|
|
62067
|
use POSIX; |
|
49
|
|
|
|
|
451815
|
|
|
49
|
|
|
|
|
398
|
|
159
|
49
|
|
|
49
|
|
268262
|
use Net::XMPP 1.0; |
|
49
|
|
|
|
|
9895232
|
|
|
49
|
|
|
|
|
1922
|
|
160
|
|
|
|
|
|
|
|
161
|
49
|
|
|
49
|
|
577
|
use base qw( Net::XMPP ); |
|
49
|
|
|
|
|
112
|
|
|
49
|
|
|
|
|
17559
|
|
162
|
|
|
|
|
|
|
|
163
|
49
|
|
|
49
|
|
363
|
use vars qw( $VERSION ); |
|
49
|
|
|
|
|
101
|
|
|
49
|
|
|
|
|
3044
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
$VERSION = "2.0"; |
166
|
|
|
|
|
|
|
|
167
|
49
|
|
|
49
|
|
41918
|
use Net::Jabber::Debug; |
|
49
|
|
|
|
|
122
|
|
|
49
|
|
|
|
|
1227
|
|
168
|
49
|
|
|
49
|
|
29948
|
use Net::Jabber::JID; |
|
49
|
|
|
|
|
124
|
|
|
49
|
|
|
|
|
1364
|
|
169
|
49
|
|
|
49
|
|
58143
|
use Net::Jabber::Namespaces; |
|
49
|
|
|
|
|
180
|
|
|
49
|
|
|
|
|
5447
|
|
170
|
49
|
|
|
49
|
|
87893
|
use Net::Jabber::Stanza; |
|
49
|
|
|
|
|
132
|
|
|
49
|
|
|
|
|
2009
|
|
171
|
49
|
|
|
49
|
|
31394
|
use Net::Jabber::Message; |
|
49
|
|
|
|
|
135
|
|
|
49
|
|
|
|
|
1379
|
|
172
|
49
|
|
|
49
|
|
32607
|
use Net::Jabber::IQ; |
|
49
|
|
|
|
|
143
|
|
|
49
|
|
|
|
|
1363
|
|
173
|
49
|
|
|
49
|
|
31510
|
use Net::Jabber::Presence; |
|
49
|
|
|
|
|
148
|
|
|
49
|
|
|
|
|
1745
|
|
174
|
49
|
|
|
49
|
|
68758
|
use Net::Jabber::Protocol; |
|
49
|
|
|
|
|
223
|
|
|
49
|
|
|
|
|
2443
|
|
175
|
49
|
|
|
49
|
|
37266
|
use Net::Jabber::Client; |
|
49
|
|
|
|
|
461
|
|
|
49
|
|
|
|
|
2202
|
|
176
|
49
|
|
|
49
|
|
40855
|
use Net::Jabber::Component; |
|
49
|
|
|
|
|
152
|
|
|
49
|
|
|
|
|
5159
|
|
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
0
|
0
|
|
sub GetTimeStamp { return &Net::XMPP::GetTimeStamp(@_); } |
179
|
0
|
|
|
0
|
0
|
|
sub printData { return &Net::XMPP::printData(@_); } |
180
|
0
|
|
|
0
|
0
|
|
sub sprintData { return &Net::XMPP::sprintData(@_); } |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |