| 1 |
elmex |
1.1 |
package Net::XMPP2; |
| 2 |
|
|
use warnings; |
| 3 |
|
|
use strict; |
| 4 |
|
|
|
| 5 |
elmex |
1.3 |
our %EXTENSION_ENABLED; |
| 6 |
|
|
|
| 7 |
elmex |
1.1 |
=head1 NAME |
| 8 |
|
|
|
| 9 |
|
|
Net::XMPP2 - An implementation of the XMPP Protocol |
| 10 |
|
|
|
| 11 |
|
|
=head1 VERSION |
| 12 |
|
|
|
| 13 |
|
|
Version 0.01 |
| 14 |
|
|
|
| 15 |
|
|
=cut |
| 16 |
|
|
|
| 17 |
|
|
our $VERSION = '0.01'; |
| 18 |
|
|
|
| 19 |
|
|
=head1 SYNOPSIS |
| 20 |
|
|
|
| 21 |
elmex |
1.2 |
use Net::XMPP2::Connection; |
| 22 |
elmex |
1.1 |
|
| 23 |
elmex |
1.2 |
or: |
| 24 |
elmex |
1.1 |
|
| 25 |
elmex |
1.2 |
use Net::XMPP2::IM::Connection; |
| 26 |
elmex |
1.1 |
|
| 27 |
elmex |
1.2 |
=head1 DESCRIPTION |
| 28 |
|
|
|
| 29 |
|
|
This is the head module of the L<Net::XMPP2> XMPP client protocol (as described in |
| 30 |
elmex |
1.4 |
RFC 3920 and RFC 3921) framework. |
| 31 |
elmex |
1.2 |
|
| 32 |
elmex |
1.4 |
L<Net::XMPP2::Connection> is a RFC 3920 conformant "XML" stream implementation |
| 33 |
elmex |
1.5 |
for clients, which handles tcp connect up to the resource binding. And provides |
| 34 |
|
|
low-level access to the XML nodes on the XML stream along with some high |
| 35 |
|
|
level methods to send the predefined XML stanzas. |
| 36 |
elmex |
1.2 |
|
| 37 |
elmex |
1.4 |
L<Net::XMPP2::IM::Connection> is a more highlevel module, which is derived |
| 38 |
|
|
from L<Net::XMPP2::Connection>. It handles all the instant messaging client |
| 39 |
elmex |
1.5 |
functionality described in RFC 3921. |
| 40 |
|
|
|
| 41 |
|
|
Some extensions for XMPP are also implemented and can be activated as described |
| 42 |
|
|
below in L<Supportet extensions>. |
| 43 |
elmex |
1.2 |
|
| 44 |
|
|
There are also other modules in this distribution, for example: |
| 45 |
|
|
L<Net::XMPP2::Util>, L<Net::XMPP2::Writer>, L<Net::XMPP2::Parser> and those i |
| 46 |
|
|
forgot :-) Those modules might be helpful and/or required if you want to use |
| 47 |
|
|
this framework for XMPP. |
| 48 |
|
|
|
| 49 |
|
|
See also L<Net::XMPP2::Writer> for a discussion about the brokeness of XML in the XMPP |
| 50 |
|
|
specification. |
| 51 |
|
|
|
| 52 |
|
|
=head1 Why (yet) another XMPP module? |
| 53 |
|
|
|
| 54 |
|
|
The main outstanding feature of this module in comparsion to the other XMPP |
| 55 |
|
|
(aka Jabber) modules out there is the support for L<AnyEvent>. L<AnyEvent> |
| 56 |
|
|
permits you to use this module together with other I/O event based programs and |
| 57 |
|
|
libraries (ie. L<Gtk2> or L<Event>). |
| 58 |
|
|
|
| 59 |
|
|
The other modules could often only be integrated in those applications or librarys |
| 60 |
elmex |
1.4 |
by using threads. I decided to write this module because i think CPAN lacks |
| 61 |
|
|
an event based XMPP module. Threads are unfortunately not an alternative in Perl |
| 62 |
|
|
at the moment due the limited threading functionality they provide and the global |
| 63 |
|
|
speed hit. I also think that a simple event based I/O framework might be a bit easier |
| 64 |
|
|
to handle than threads. |
| 65 |
elmex |
1.2 |
|
| 66 |
|
|
Another thing was that I didn't like the APIs of the other modules. In L<Net::XMPP2> |
| 67 |
elmex |
1.4 |
i try to provide low level modules for speaking XMPP as defined in RFC 3920 and RFC 3921 |
| 68 |
|
|
(see also L<Net::XMPP2::Connection> and L<Net::XMPP2::IM::Connection>). But i also |
| 69 |
elmex |
1.5 |
try to provide a high level API. |
| 70 |
elmex |
1.2 |
|
| 71 |
elmex |
1.4 |
I also try to have all additional features and functionality as optional as possible |
| 72 |
|
|
to give the client writers enough freedom. |
| 73 |
elmex |
1.2 |
|
| 74 |
|
|
=head1 A note about TLS |
| 75 |
|
|
|
| 76 |
|
|
This module also supports TLS, as the specification of XMPP requires an |
| 77 |
elmex |
1.7 |
implementation to support TLS. |
| 78 |
elmex |
1.2 |
|
| 79 |
|
|
There are maybe still some bugs in the handling of TLS in L<Net::XMPP2::Connection>. |
| 80 |
elmex |
1.7 |
So keep an eye on TLS with this module. If you encounter any problems it would be |
| 81 |
|
|
very helpful if you could debug them or at least send me a detailed report on how |
| 82 |
|
|
to reproduce the problem. |
| 83 |
|
|
|
| 84 |
|
|
(As I use this module myself I don't expect TLS to be completly broken, but it |
| 85 |
|
|
might break under different circumstances than I have here. Those |
| 86 |
|
|
circumstances might be a different load of data pumped through the TLS |
| 87 |
|
|
connection.) |
| 88 |
elmex |
1.1 |
|
| 89 |
elmex |
1.2 |
I mainly expect problems where aviable data isn't properly read from the socket |
| 90 |
|
|
or written to it. You might want to take a look at the C<debug_send> and C<debug_recv> |
| 91 |
|
|
events in L<Net::XMPP2::Connection>. |
| 92 |
elmex |
1.1 |
|
| 93 |
elmex |
1.4 |
=head1 Supportet extensions |
| 94 |
elmex |
1.3 |
|
| 95 |
|
|
You can extend the functionality of this modules either by giving C<use Net::XMPP2> |
| 96 |
|
|
an argument like this: |
| 97 |
|
|
|
| 98 |
|
|
use Net::XMPP2 qw/xep-0086/; |
| 99 |
|
|
|
| 100 |
elmex |
1.6 |
There are other extensions that don't change the behaviour of the client |
| 101 |
|
|
to the outside, those are implemented silently. They are listed below the |
| 102 |
|
|
list of supported XMPP extensions. |
| 103 |
|
|
|
| 104 |
|
|
=head2 List of supported extensions |
| 105 |
|
|
|
| 106 |
elmex |
1.3 |
This is the list of supported XMPP extensions: |
| 107 |
|
|
|
| 108 |
|
|
=over 4 |
| 109 |
|
|
|
| 110 |
|
|
=item XEP-0086 - Error Condition Mappings |
| 111 |
|
|
|
| 112 |
|
|
"A mapping to enable legacy entities to correctly handle errors from XMPP-aware entities." |
| 113 |
|
|
|
| 114 |
|
|
This extension will enable sending of the old error codes when generating a stanza |
| 115 |
|
|
error with for example: L<Net::XMPP2::Writer::write_error_tag> |
| 116 |
|
|
|
| 117 |
elmex |
1.8 |
=item XEP-0077 - In-Band Registration |
| 118 |
|
|
|
| 119 |
|
|
This extension lets you register new accounts "in-band". |
| 120 |
|
|
To use this look at the description of the C<register> option to the C<new> |
| 121 |
|
|
method of L<Net::XMPP2::Connection>. |
| 122 |
|
|
|
| 123 |
elmex |
1.3 |
=back |
| 124 |
|
|
|
| 125 |
elmex |
1.6 |
=head2 List of silently supported extensions |
| 126 |
|
|
|
| 127 |
|
|
This is the list of silently supported extensions which don'tt |
| 128 |
|
|
change the behaviour of the modules. |
| 129 |
|
|
|
| 130 |
|
|
=over 4 |
| 131 |
|
|
|
| 132 |
|
|
=back |
| 133 |
|
|
|
| 134 |
elmex |
1.3 |
=cut |
| 135 |
|
|
|
| 136 |
|
|
sub import { |
| 137 |
|
|
my ($mod, @exts) = @_; |
| 138 |
|
|
for (@exts) { |
| 139 |
|
|
if (/^xep-(\d+)$/i) { |
| 140 |
|
|
$EXTENSION_ENABLED{''. (1*$1)} = 1; |
| 141 |
|
|
} |
| 142 |
|
|
} |
| 143 |
|
|
} |
| 144 |
|
|
|
| 145 |
elmex |
1.1 |
=head1 AUTHOR |
| 146 |
|
|
|
| 147 |
|
|
Robin Redeker, C<< <elmex at ta-sa.org> >> |
| 148 |
|
|
|
| 149 |
|
|
=head1 BUGS |
| 150 |
|
|
|
| 151 |
|
|
Please report any bugs or feature requests to |
| 152 |
|
|
C<bug-net-xmpp2 at rt.cpan.org>, or through the web interface at |
| 153 |
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-XMPP2>. |
| 154 |
|
|
I will be notified, and then you'll automatically be notified of progress on |
| 155 |
|
|
your bug as I make changes. |
| 156 |
|
|
|
| 157 |
|
|
=head1 SUPPORT |
| 158 |
|
|
|
| 159 |
|
|
You can find documentation for this module with the perldoc command. |
| 160 |
|
|
|
| 161 |
|
|
perldoc Net::XMPP2 |
| 162 |
|
|
|
| 163 |
|
|
You can also look for information at: |
| 164 |
|
|
|
| 165 |
|
|
=over 4 |
| 166 |
|
|
|
| 167 |
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
| 168 |
|
|
|
| 169 |
|
|
L<http://annocpan.org/dist/Net-XMPP2> |
| 170 |
|
|
|
| 171 |
|
|
=item * CPAN Ratings |
| 172 |
|
|
|
| 173 |
|
|
L<http://cpanratings.perl.org/d/Net-XMPP2> |
| 174 |
|
|
|
| 175 |
|
|
=item * RT: CPAN's request tracker |
| 176 |
|
|
|
| 177 |
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-XMPP2> |
| 178 |
|
|
|
| 179 |
|
|
=item * Search CPAN |
| 180 |
|
|
|
| 181 |
|
|
L<http://search.cpan.org/dist/Net-XMPP2> |
| 182 |
|
|
|
| 183 |
|
|
=back |
| 184 |
|
|
|
| 185 |
|
|
=head1 ACKNOWLEDGEMENTS |
| 186 |
|
|
|
| 187 |
|
|
=head1 COPYRIGHT & LICENSE |
| 188 |
|
|
|
| 189 |
|
|
Copyright 2007 Robin Redeker, all rights reserved. |
| 190 |
|
|
|
| 191 |
|
|
This program is free software; you can redistribute it and/or modify it |
| 192 |
|
|
under the same terms as Perl itself. |
| 193 |
|
|
|
| 194 |
|
|
=cut |
| 195 |
|
|
|
| 196 |
|
|
1; # End of Net::XMPP2 |