1 |
package Net::XMPP2; |
2 |
use warnings; |
3 |
use strict; |
4 |
|
5 |
=head1 NAME |
6 |
|
7 |
Net::XMPP2 - An implementation of the XMPP Protocol |
8 |
|
9 |
=head1 VERSION |
10 |
|
11 |
Version 0.04 |
12 |
|
13 |
=cut |
14 |
|
15 |
our $VERSION = '0.04'; |
16 |
|
17 |
=head1 SYNOPSIS |
18 |
|
19 |
use Net::XMPP2::Connection; |
20 |
|
21 |
or: |
22 |
|
23 |
use Net::XMPP2::IM::Connection; |
24 |
|
25 |
or: |
26 |
|
27 |
use Net::XMPP2::Client; |
28 |
|
29 |
=head1 DESCRIPTION |
30 |
|
31 |
This is the head module of the L<Net::XMPP2> XMPP client protocol (as described in |
32 |
RFC 3920 and RFC 3921) framework. |
33 |
|
34 |
L<Net::XMPP2::Connection> is a RFC 3920 conformant "XML" stream implementation |
35 |
for clients, which handles TCP connect up to the resource binding. And provides |
36 |
low level access to the XML nodes on the XML stream along with some high |
37 |
level methods to send the predefined XML stanzas. |
38 |
|
39 |
L<Net::XMPP2::IM::Connection> is a more high level module, which is derived |
40 |
from L<Net::XMPP2::Connection>. It handles all the instant messaging client |
41 |
functionality described in RFC 3921. |
42 |
|
43 |
L<Net::XMPP2::Client> is a multi account client class. It manages connections |
44 |
to multiple XMPP accounts and tries to offer a nice high level interface |
45 |
to XMPP communication. |
46 |
|
47 |
For a list of L</Supported extensions> see below. |
48 |
|
49 |
There are also other modules in this distribution, for example: |
50 |
L<Net::XMPP2::Util>, L<Net::XMPP2::Writer>, L<Net::XMPP2::Parser> and those I |
51 |
forgot :-) Those modules might be helpful and/or required if you want to use |
52 |
this framework for XMPP. |
53 |
|
54 |
See also L<Net::XMPP2::Writer> for a discussion about the brokeness of XML in the XMPP |
55 |
specification. |
56 |
|
57 |
If you have any questions or seek for help look below under L</SUPPORT>. |
58 |
|
59 |
=head1 REQUIREMENTS |
60 |
|
61 |
One of the major drawbacks I see for Net::XMPP2 is the long list of required |
62 |
modules to make it work. |
63 |
|
64 |
=over 4 |
65 |
|
66 |
=item L<AnyEvent> |
67 |
|
68 |
For the I/O events and timers. |
69 |
|
70 |
=item L<XML::Writer> |
71 |
|
72 |
For writing "XML". |
73 |
|
74 |
=item L<XML::Parser::Expat> |
75 |
|
76 |
For parsing partial "XML" stuff. |
77 |
|
78 |
=item L<MIME::Base64> |
79 |
|
80 |
For SASL authentication |
81 |
|
82 |
=item L<Authen::SASL> |
83 |
|
84 |
For SASL authentication |
85 |
|
86 |
=item L<Net::LibIDN> |
87 |
|
88 |
For stringprep profiles to handle JIDs. |
89 |
|
90 |
=item L<Net::SSLeay> |
91 |
|
92 |
For SSL connections. |
93 |
|
94 |
=item L<Net::DNS> |
95 |
|
96 |
For SRV RR lookups. |
97 |
|
98 |
=item L<Digest::SHA1> |
99 |
|
100 |
For component authentication. |
101 |
|
102 |
=back |
103 |
|
104 |
And yes, all these are essential for XMPP communication. Even though 'instant |
105 |
messaging' and 'presence' is a quite simple problem XMPP somehow was successful |
106 |
at making the task complicated enough to keep me busy for a long time. But all |
107 |
of that time wasn't only for the technology required to get it started, mostly |
108 |
it was for all the quirks, hacks and badly applied "XML" in the protocol which |
109 |
complicated the matter. |
110 |
|
111 |
=head1 RELEASE NOTES |
112 |
|
113 |
Here are some notes to the releases (release of this version is at top): |
114 |
|
115 |
=head2 Version |
116 |
|
117 |
=over 4 |
118 |
|
119 |
=item * 0.04 |
120 |
|
121 |
After realizing that in band registration in L<Net::XMPP2::Ext> was already |
122 |
in in version 0.03 I finally had to implement it. |
123 |
|
124 |
While implementing in band registration I implemented XEP-0066: Out of Band Data. |
125 |
You can now receive and send URLs from and to others. See also L<Net::XMPP2::Ext::OOB>. |
126 |
|
127 |
I also fixed some bugs in L<Net::XMPP2::Ext::Disco>. |
128 |
|
129 |
=item * 0.03 |
130 |
|
131 |
This release adds new events for attaching information to "XML" stanzas that |
132 |
are in transmission to the server. See also the events C<send_*_hook> in |
133 |
L<Net::XMPP2::Connection>. |
134 |
|
135 |
The event callbacks als don't have to return a true value anymore. What the |
136 |
return values do depends on the event now. |
137 |
|
138 |
The highlight of this release is the implementation of XEP-0114, the Jabber |
139 |
Component Protocol. |
140 |
|
141 |
It's possible to get a DOM tree from a L<Net::XMPP2::Node> now and also to |
142 |
receive the original parsed "XML" from it, which should enable full access to |
143 |
the "XML" data that was received. This also allows easy integration with other |
144 |
XML Perl modules. |
145 |
|
146 |
You can also set the initial priority of the presence in |
147 |
L<Net::XMPP2::IM::Connection> now. |
148 |
|
149 |
Please consult the Changes file for greater detail about bugfixes and new |
150 |
features. |
151 |
|
152 |
=item * 0.02 |
153 |
|
154 |
This release adds lots of small improvements to the API (mostly new events), |
155 |
and also some bugfixes here and there. The release also comes with some |
156 |
new examples, you might want to take a look at the L</EXAMPLES> section. |
157 |
|
158 |
As a highlight I also present the implementation of XEP-0004 (Data Forms), see also |
159 |
L<Net::XMPP2::Ext> for a description. |
160 |
|
161 |
I also added some convenience functions to L<Net::XMPP2::Util>, for example |
162 |
C<simxml> which simplifies the generation of XMPP-like "XML". |
163 |
|
164 |
=item * 0.01 |
165 |
|
166 |
This release has beta status. The code is already used daily in my client |
167 |
and I keep looking out for bugs. If you find undocumented, missing or faulty |
168 |
code/methods please drop me a mail! See also L</BUGS> below. |
169 |
|
170 |
Potential edges when using this module: sparely documented methods, missing |
171 |
functionality and generally bugs bugs and bugs. Even though this module is in |
172 |
daily usage there are still lots of cases I might have missed. |
173 |
|
174 |
For the next release I'm planning to provide more examples in the documentation |
175 |
and/or samples/ directory, along with bugfixes and enhancements along with some |
176 |
todo items killed from the TODO file. |
177 |
|
178 |
=back |
179 |
|
180 |
=head2 TODO |
181 |
|
182 |
There are still lots of items on the TODO list (see also the TODO file |
183 |
in the distribution of Net::XMPP2). |
184 |
|
185 |
=head1 Why (yet) another XMPP module? |
186 |
|
187 |
The main outstanding feature of this module in comparison to the other XMPP |
188 |
(aka Jabber) modules out there is the support for L<AnyEvent>. L<AnyEvent> |
189 |
permits you to use this module together with other I/O event based programs and |
190 |
libraries (ie. L<Gtk2> or L<Event>). |
191 |
|
192 |
The other modules could often only be integrated in those applications or |
193 |
libraries by using threads. I decided to write this module because I think CPAN |
194 |
lacks an event based XMPP module. Threads are unfortunately not an alternative |
195 |
in Perl at the moment due the limited threading functionality they provide and |
196 |
the global speed hit. I also think that a simple event based I/O framework |
197 |
might be a bit easier to handle than threads. |
198 |
|
199 |
Another thing was that I didn't like the APIs of the other modules. In L<Net::XMPP2> |
200 |
I try to provide low level modules for speaking XMPP as defined in RFC 3920 and RFC 3921 |
201 |
(see also L<Net::XMPP2::Connection> and L<Net::XMPP2::IM::Connection>). But I also |
202 |
try to provide a high level API for easier usage for instant messaging tasks |
203 |
and clients (eg. L<Net::XMPP2::Client>). |
204 |
|
205 |
=head1 A note about TLS |
206 |
|
207 |
This module also supports TLS, as the specification of XMPP requires an |
208 |
implementation to support TLS. |
209 |
|
210 |
Maybe there are still some bugs in the handling of TLS in L<Net::XMPP2::Connection>. |
211 |
So keep an eye on TLS with this module. If you encounter any problems it would be |
212 |
very helpful if you could debug them or at least send me a detailed report on how |
213 |
to reproduce the problem. |
214 |
|
215 |
(As I use this module myself I don't expect TLS to be completly broken, but it |
216 |
might break under different circumstances than I have here. Those |
217 |
circumstances might be a different load of data pumped through the TLS |
218 |
connection.) |
219 |
|
220 |
I mainly expect problems where available data isn't properly read from the socket |
221 |
or written to it. You might want to take a look at the C<debug_send> and C<debug_recv> |
222 |
events in L<Net::XMPP2::Connection>. |
223 |
|
224 |
=head1 Supported extensions |
225 |
|
226 |
See L<Net::XMPP2::Ext> for a list. |
227 |
|
228 |
=head1 EXAMPLES |
229 |
|
230 |
Following examples are included in this distribution: |
231 |
|
232 |
=over 4 |
233 |
|
234 |
=item B<samples/simple_example_1> |
235 |
|
236 |
This example script just connects to a server and sends a message and |
237 |
also displays incoming messages on stdout. |
238 |
|
239 |
=item B<samples/devcl/devcl> |
240 |
|
241 |
This is a more advanced 'example'. It requires you to have L<Gtk2> |
242 |
installed. It's mostly used by the author to implement proof-of-concepts. |
243 |
Currently you start the client like this: |
244 |
|
245 |
../Net-XMPP2/samples/devcl/# perl ./devcl <jid> <password> |
246 |
|
247 |
The client's main window displays a protocol dump and there is currently |
248 |
a service discovery browser implemented. |
249 |
|
250 |
This might be a valuable source if you look for more real-world |
251 |
applications of L<Net::XMPP2>. |
252 |
|
253 |
=item B<samples/conference_lister> |
254 |
|
255 |
See below. |
256 |
|
257 |
=item B<samples/room_lister> |
258 |
|
259 |
See below. |
260 |
|
261 |
=item B<samples/room_lister_stat> |
262 |
|
263 |
These three scripts implements a global room scan. C<conference_lister> takes |
264 |
a list of servers (the file is called C<servers.xml> which has the same format as |
265 |
the xml file at L<http://www.jabber.org/servers.xml>). It then scans all |
266 |
servers for chat room services and lists them into a file C<conferences.stor>, |
267 |
which is a L<Storable> dump. |
268 |
|
269 |
C<room_lister> then reads that file and queries all services for rooms, and then |
270 |
all rooms for their occupants. The output file is C<room_data.stor>, also a L<Storable> |
271 |
dump, which in turn can be read with C<room_lister_stat>, which transform |
272 |
the data structures into something human readable. |
273 |
|
274 |
These scripts are a bit hacky and quite complicated, but maybe it's of any |
275 |
value for someone. You might note L<samples/EVQ.pm> which is a module that |
276 |
handles request-throttling (You don't want to flood the server and risk |
277 |
getting the admins attention :). |
278 |
|
279 |
=item B<samples/simple_component> |
280 |
|
281 |
This is a (basic) skeleton for a jabber component. |
282 |
|
283 |
=item B<samples/simple_oob_retriever> |
284 |
|
285 |
This is a simple out of band file transfer receiver bot. It uses C<curl> to |
286 |
fetch the files and also has the sample functionality of sending a file url for |
287 |
someone who sends the bot a 'send <filename>' message. |
288 |
|
289 |
=item B<samples/simple_register_example> |
290 |
|
291 |
This is a example script which allows you to register, unregister and change |
292 |
your password for accounts. Execute it without arguments for more details. |
293 |
|
294 |
=back |
295 |
|
296 |
For others, which the author might forgot or didn't want to |
297 |
list here see the C<samples/> directory. |
298 |
|
299 |
More examples will be included in later releases, please feel free to ask the |
300 |
L</AUTHOR> if you have any questions about the API. There is also an IRC |
301 |
channel, see L</SUPPORT>. |
302 |
|
303 |
=head1 AUTHOR |
304 |
|
305 |
Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >> |
306 |
|
307 |
=head1 BUGS |
308 |
|
309 |
Please note that I'm currently (July 2007) the only developer on this project |
310 |
and I'm very busy with my studies in Computer Science in Summer 2007. If you |
311 |
want to ease my workload or want timely releases, please send me patches instead |
312 |
of bug reports or feature requests. I won't forget the reports or requests if |
313 |
you can't or didn't send patches, but I can't gurantee immediate response. |
314 |
But I will of course try to fix/implement them as soon as possible! |
315 |
|
316 |
Also try to be as precise as possible with bug reports, if you can't send a |
317 |
patch, it would be best if you find out which code doesn't work and tell me |
318 |
why. |
319 |
|
320 |
Please report any bugs or feature requests to |
321 |
C<bug-net-xmpp2 at rt.cpan.org>, or through the web interface at |
322 |
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-XMPP2>. |
323 |
I will be notified and then you'll automatically be notified of progress on |
324 |
your bug as I make changes. |
325 |
|
326 |
=head1 SUPPORT |
327 |
|
328 |
You can find documentation for this module with the perldoc command. |
329 |
|
330 |
perldoc Net::XMPP2 |
331 |
|
332 |
You can also look for information at: |
333 |
|
334 |
=over 4 |
335 |
|
336 |
=item * IRC: Net::XMPP2 IRC Channel |
337 |
|
338 |
IRC Network: http://freenode.net/ |
339 |
Server : chat.freenode.net |
340 |
Channel : #net_xmpp2 |
341 |
|
342 |
Feel free to join and ask questions! |
343 |
|
344 |
=item * Net::XMPP2 Project Site |
345 |
|
346 |
L<http://www.ta-sa.org/> |
347 |
|
348 |
=item * AnnoCPAN: Annotated CPAN documentation |
349 |
|
350 |
L<http://annocpan.org/dist/Net-XMPP2> |
351 |
|
352 |
=item * CPAN Ratings |
353 |
|
354 |
L<http://cpanratings.perl.org/d/Net-XMPP2> |
355 |
|
356 |
=item * RT: CPAN's request tracker |
357 |
|
358 |
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-XMPP2> |
359 |
|
360 |
=item * Search CPAN |
361 |
|
362 |
L<http://search.cpan.org/dist/Net-XMPP2> |
363 |
|
364 |
=back |
365 |
|
366 |
=head1 ACKNOWLEDGEMENTS |
367 |
|
368 |
Thanks to the XSF for the development of an open instant messaging protocol (even though it uses "XML"). |
369 |
|
370 |
And thanks to all people who had to listen to my desperate curses about the |
371 |
brokenness/braindeadness of XMPP. Without you I would've never brought this |
372 |
module to a usable state. |
373 |
|
374 |
Thanks to: |
375 |
|
376 |
=over 4 |
377 |
|
378 |
=item * Carlo von Loesch (aka lynX) L<http://www.psyced.org/> |
379 |
|
380 |
For pointing out some typos. |
381 |
|
382 |
=back |
383 |
|
384 |
=head1 COPYRIGHT & LICENSE |
385 |
|
386 |
Copyright 2007 Robin Redeker, all rights reserved. |
387 |
|
388 |
This program is free software; you can redistribute it and/or modify it |
389 |
under the same terms as Perl itself. |
390 |
|
391 |
=cut |
392 |
|
393 |
1; # End of Net::XMPP2 |