| 1 | package AnyEvent::XMPP; | ||
| 2 | 6 | ▶ | no warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | AnyEvent::XMPP - An implementation of the XMPP Protocol | ||
| 8 | |||
| 9 | =head1 VERSION | ||
| 10 | |||
| 11 | Version 0.55 | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | 6 | our $VERSION = '0.55'; | |
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | use AnyEvent::XMPP::Connection; | ||
| 20 | |||
| 21 | or: | ||
| 22 | |||
| 23 | use AnyEvent::XMPP::IM::Connection; | ||
| 24 | |||
| 25 | or: | ||
| 26 | |||
| 27 | use AnyEvent::XMPP::Client; | ||
| 28 | |||
| 29 | =head1 DESCRIPTION | ||
| 30 | |||
| 31 | This is the head module of the L<AnyEvent::XMPP> XMPP client protocol (as described in | ||
| 32 | RFC 3920 and RFC 3921) framework. | ||
| 33 | |||
| 34 | L<AnyEvent::XMPP::Connection> is a RFC 3920 conforming "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<AnyEvent::XMPP::IM::Connection> is a more high level module, which is derived | ||
| 40 | from L<AnyEvent::XMPP::Connection>. It handles all the instant messaging client | ||
| 41 | functionality described in RFC 3921. | ||
| 42 | |||
| 43 | L<AnyEvent::XMPP::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<AnyEvent::XMPP::Util>, L<AnyEvent::XMPP::Writer>, L<AnyEvent::XMPP::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<AnyEvent::XMPP::Writer> for a discussion about the brokenness 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 AnyEvent::XMPP 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, timers, TCP, TLS, DNS and I/O buffering. | ||
| 69 | |||
| 70 | =item L<Object::Event> | ||
| 71 | |||
| 72 | The former L<AnyEvent::XMPP::Event> module has been outsourced to the L<Object::Event> | ||
| 73 | module to provide a more generic way for more other modules to register and call | ||
| 74 | event callbacks. | ||
| 75 | |||
| 76 | =item L<XML::Writer> | ||
| 77 | |||
| 78 | For writing "XML". | ||
| 79 | |||
| 80 | =item L<XML::Parser::Expat> | ||
| 81 | |||
| 82 | For parsing partial "XML" stuff. | ||
| 83 | |||
| 84 | =item L<MIME::Base64> | ||
| 85 | |||
| 86 | For SASL authentication | ||
| 87 | |||
| 88 | =item L<Authen::SASL> | ||
| 89 | |||
| 90 | For SASL authentication | ||
| 91 | |||
| 92 | =item L<Net::LibIDN> | ||
| 93 | |||
| 94 | For stringprep profiles to handle JIDs. | ||
| 95 | |||
| 96 | =item L<Digest::SHA> | ||
| 97 | |||
| 98 | For component authentication and old-style authentication. | ||
| 99 | |||
| 100 | =back | ||
| 101 | |||
| 102 | And yes, all these are essential for XMPP communication. Even though 'instant | ||
| 103 | messaging' and 'presence' is a quite simple problem XMPP somehow was successful | ||
| 104 | at making the task complicated enough to keep me busy for a long time. But all | ||
| 105 | of that time wasn't only for the technology required to get it started, mostly | ||
| 106 | it was for all the quirks, hacks and badly applied "XML" in the protocol which | ||
| 107 | complicated the matter. | ||
| 108 | |||
| 109 | =head1 RELEASE NOTES | ||
| 110 | |||
| 111 | Here are some notes to the last releases (release of this version is at top): | ||
| 112 | |||
| 113 | =head2 Version | ||
| 114 | |||
| 115 | =over 4 | ||
| 116 | |||
| 117 | =item * 0.55 | ||
| 118 | |||
| 119 | Bugfixes, see Changes file. | ||
| 120 | |||
| 121 | =item * 0.54 | ||
| 122 | |||
| 123 | Add L<AnyEvent::XMPP::Ext::Receipts>, small bugfixes, see Changes file. | ||
| 124 | |||
| 125 | =item * 0.53 | ||
| 126 | |||
| 127 | Maintenance release. Patches for various small issues, see Changes file. | ||
| 128 | |||
| 129 | =item * 0.52 | ||
| 130 | |||
| 131 | Maintenance release. | ||
| 132 | |||
| 133 | =item * 0.51 | ||
| 134 | |||
| 135 | Maintenance release. Added a patch which fixes L<Object::Event> compatibility | ||
| 136 | and another fix w.r.t. memory leak in the parser. And added the original node | ||
| 137 | to L<AnyEvent::XMPP::IM::Message> (thanks go to mons@cpan.org). | ||
| 138 | |||
| 139 | B<NOTE:> Version 0.6 of L<AnyEvent::XMPP> will be API incompatible! If you | ||
| 140 | are already eager to try the new version out contact me! | ||
| 141 | |||
| 142 | =item * 0.5 | ||
| 143 | |||
| 144 | Maintenance release. Added a patch from Marcus Dubois for Ext::Pubsub. | ||
| 145 | Also fixed some memleaks in L<AnyEvent::XMPP::Parser>. | ||
| 146 | |||
| 147 | Also wanted to note that the next version of AnyEvent::XMPP will have an | ||
| 148 | incompatible API. If you are eager to try out the new complete rewrite of | ||
| 149 | AnyEvent::XMPP contact me. | ||
| 150 | |||
| 151 | =item * 0.4 | ||
| 152 | |||
| 153 | Minor fixes and feature enhancements: Added old_style_ssl option for direct | ||
| 154 | port 5223 SSL connections. Providing 'get_own_contact' for keeping | ||
| 155 | track of own resources. | ||
| 156 | |||
| 157 | The L<AnyEvent::XMPP::Ext::MUC> extension was rewritten and provides a more | ||
| 158 | sane API now. | ||
| 159 | |||
| 160 | For details consult the Changes file in the distribution. | ||
| 161 | |||
| 162 | =item * 0.3 | ||
| 163 | |||
| 164 | Fixed some small bugs and improved documentation a bit, especially w.r.t. | ||
| 165 | parameter passing of host and ports. | ||
| 166 | |||
| 167 | =item * 0.2 | ||
| 168 | |||
| 169 | Renamed module from L<Net::XMPP2> to L<AnyEvent::XMPP>. L<Net::XMPP2> is herby | ||
| 170 | deprecated! | ||
| 171 | |||
| 172 | Rewrote the low-level socket stuff to use L<AnyEvent::Socket> and L<AnyEvent::Handle>. | ||
| 173 | Removed blocking write functionality, which can't be supported that | ||
| 174 | easily with L<AnyEvent::Handle> (however, if you want to wait until the send-buffer | ||
| 175 | is empty you best use the C<send_buffer_empty> event of L<AnyEvent::XMPP::Connection>). | ||
| 176 | |||
| 177 | For more details consult the Changes file of the AnyEvent::XMPP distribution. | ||
| 178 | |||
| 179 | =item * older | ||
| 180 | |||
| 181 | For older release notes please have a look at the Changes file or CPAN. | ||
| 182 | |||
| 183 | =back | ||
| 184 | |||
| 185 | =head2 TODO | ||
| 186 | |||
| 187 | There are still lots of items on the TODO list (see also the TODO file | ||
| 188 | in the distribution of AnyEvent::XMPP). | ||
| 189 | |||
| 190 | =head1 TEST SUITE | ||
| 191 | |||
| 192 | If you are a developer and want to test either a server or maybe just whether | ||
| 193 | this module passes some basic tests you might want to run the developer test | ||
| 194 | suite. | ||
| 195 | |||
| 196 | This test suite is not enabled by default because it requires some human | ||
| 197 | interaction to set it up, please see L<AnyEvent::XMPP::TestClient> for hints about | ||
| 198 | the setup procedure for the test suite. | ||
| 199 | |||
| 200 | I wrote the test suite mostly because I wanted to make sure I didn't break | ||
| 201 | something essential before a release. The tests don't cover everything and I | ||
| 202 | don't plan to write a test for every single function in the API, that would | ||
| 203 | slow down development considerably for me. But I hope that some grave show | ||
| 204 | stopper bugs in releases are prevented with this test suite. | ||
| 205 | |||
| 206 | The tests are also useful if you want to test a server implementation. But | ||
| 207 | there are maybe of course conformance issues with L<AnyEvent::XMPP> itself, so if | ||
| 208 | you find something where L<AnyEvent::XMPP> doesn't conform to the XMPP RFCs or XEPs | ||
| 209 | consult the L<BUGS> section below. | ||
| 210 | |||
| 211 | If you find a server that doesn't handle something correctly but you need to | ||
| 212 | interact with it you are free to implement workarounds and send me a patch, or | ||
| 213 | even ask me whether I might want to look into the issue (I can't guarantee | ||
| 214 | anything here, but I want this module to be as interoperable as possible. But | ||
| 215 | if the implementation of a workaround for some non-conformant software will | ||
| 216 | complicate the code too much I'm probably not going to implement it.). | ||
| 217 | |||
| 218 | Of course, if you find a bug in some server implementation don't forget to file | ||
| 219 | a bugreport to them, one hack less in L<AnyEvent::XMPP> means more time for bug | ||
| 220 | fixing and improvements and new features. | ||
| 221 | |||
| 222 | =head1 Why (yet) another XMPP module? | ||
| 223 | |||
| 224 | The main outstanding feature of this module in comparison to the other XMPP | ||
| 225 | (aka Jabber) modules out there is the support for L<AnyEvent>. L<AnyEvent> | ||
| 226 | permits you to use this module together with other I/O event based programs and | ||
| 227 | libraries (ie. L<Gtk2> or L<Event>). | ||
| 228 | |||
| 229 | The other modules could often only be integrated in those applications or | ||
| 230 | libraries by using threads. I decided to write this module because I think CPAN | ||
| 231 | lacks an event based XMPP module. Threads are unfortunately not an alternative | ||
| 232 | in Perl at the moment due the limited threading functionality they provide and | ||
| 233 | the global speed hit. I also think that a simple event based I/O framework | ||
| 234 | might be a bit easier to handle than threads. | ||
| 235 | |||
| 236 | Another thing was that I didn't like the APIs of the other modules. In | ||
| 237 | L<AnyEvent::XMPP> I try to provide low level modules for speaking XMPP as defined | ||
| 238 | in RFC 3920 and RFC 3921 (see also L<AnyEvent::XMPP::Connection> and | ||
| 239 | L<AnyEvent::XMPP::IM::Connection>). But I also try to provide a high level API for | ||
| 240 | easier usage for instant messaging tasks and clients (eg. L<AnyEvent::XMPP::Client>). | ||
| 241 | |||
| 242 | =head1 Supported extensions | ||
| 243 | |||
| 244 | See L<AnyEvent::XMPP::Ext> for a list. | ||
| 245 | |||
| 246 | =head1 EXAMPLES | ||
| 247 | |||
| 248 | Following examples are included in this distribution: | ||
| 249 | |||
| 250 | =over 4 | ||
| 251 | |||
| 252 | =item B<samples/simple_example_1> | ||
| 253 | |||
| 254 | This example script just connects to a server and sends a message and | ||
| 255 | also displays incoming messages on stdout. | ||
| 256 | |||
| 257 | =item B<samples/conference_lister> | ||
| 258 | |||
| 259 | See below. | ||
| 260 | |||
| 261 | =item B<samples/room_lister> | ||
| 262 | |||
| 263 | See below. | ||
| 264 | |||
| 265 | =item B<samples/room_lister_stat> | ||
| 266 | |||
| 267 | These three scripts implements a global room scan. C<conference_lister> takes | ||
| 268 | a list of servers (the file is called C<servers.xml> which has the same format as | ||
| 269 | the xml file at L<http://www.jabber.org/servers.xml>). It then scans all | ||
| 270 | servers for chat room services and lists them into a file C<conferences.stor>, | ||
| 271 | which is a L<Storable> dump. | ||
| 272 | |||
| 273 | C<room_lister> then reads that file and queries all services for rooms, and then | ||
| 274 | all rooms for their occupants. The output file is C<room_data.stor>, also a L<Storable> | ||
| 275 | dump, which in turn can be read with C<room_lister_stat>, which transform | ||
| 276 | the data structures into something human readable. | ||
| 277 | |||
| 278 | These scripts are a bit hacky and quite complicated, but maybe it's of any | ||
| 279 | value for someone. You might note L<samples/EVQ.pm> which is a module that | ||
| 280 | handles request-throttling (You don't want to flood the server and risk | ||
| 281 | getting the admins attention :). | ||
| 282 | |||
| 283 | =item B<samples/simple_component> | ||
| 284 | |||
| 285 | This is a (basic) skeleton for a jabber component. | ||
| 286 | |||
| 287 | =item B<samples/simple_oob_retriever> | ||
| 288 | |||
| 289 | This is a simple out of band file transfer receiver bot. It uses C<curl> to | ||
| 290 | fetch the files and also has the sample functionality of sending a file url for | ||
| 291 | someone who sends the bot a 'send <filename>' message. | ||
| 292 | |||
| 293 | =item B<samples/simple_register_example> | ||
| 294 | |||
| 295 | This is a example script which allows you to register, unregister and change | ||
| 296 | your password for accounts. Execute it without arguments for more details. | ||
| 297 | |||
| 298 | =item B<samples/disco_info> | ||
| 299 | |||
| 300 | This is a small example tool that allows you to fetch the software version, | ||
| 301 | disco info and disco items information about a JID. | ||
| 302 | |||
| 303 | =item B<samples/talkbot> | ||
| 304 | |||
| 305 | This is a simple bot that will read lines from a file and recite them | ||
| 306 | when you send it a message. It will also automatically allow you to subscribe | ||
| 307 | to it. Start it without commandline arguments to be informed about the usage. | ||
| 308 | |||
| 309 | =item B<samples/retrieve_roster> | ||
| 310 | |||
| 311 | This is a simple example script that will retrieve the roster | ||
| 312 | for an account and print it to stdout. You start it like this: | ||
| 313 | |||
| 314 | samples/# ./retrieve_roster <jid> <password> | ||
| 315 | |||
| 316 | =item B<samples/display_avatar> | ||
| 317 | |||
| 318 | This is just a small example which should display the avatar | ||
| 319 | of the account you connect to. It can be used like this: | ||
| 320 | |||
| 321 | samples/# ./display_avatar <jid> <password> | ||
| 322 | |||
| 323 | =back | ||
| 324 | |||
| 325 | For others, which the author might forgot or didn't want to | ||
| 326 | list here see the C<samples/> directory. | ||
| 327 | |||
| 328 | More examples will be included in later releases, please feel free to ask the | ||
| 329 | L</AUTHOR> if you have any questions about the API. There is also an IRC | ||
| 330 | channel, see L</SUPPORT>. | ||
| 331 | |||
| 332 | =head1 AUTHOR | ||
| 333 | |||
| 334 | Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >> | ||
| 335 | |||
| 336 | =head1 BUGS | ||
| 337 | |||
| 338 | Please note that I'm currently (July 2007) the only developer on this project | ||
| 339 | and I'm very busy with my studies in Computer Science. If you want to ease my | ||
| 340 | workload or want timely releases, please send me patches instead of bug reports | ||
| 341 | or feature requests. I won't forget the reports or requests if you can't or | ||
| 342 | didn't send patches, but I can't gurantee immediate response. But I will of | ||
| 343 | course try to fix/implement them as soon as possible! | ||
| 344 | |||
| 345 | Also try to be as precise as possible with bug reports, if you can't send a | ||
| 346 | patch, it would be best if you find out which code doesn't work and tell me | ||
| 347 | why. | ||
| 348 | |||
| 349 | Please report any bugs or feature requests to | ||
| 350 | C<bug-net-xmpp2 at rt.cpan.org>, or through the web interface at | ||
| 351 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-XMPP>. | ||
| 352 | I will be notified and then you'll automatically be notified of progress on | ||
| 353 | your bug as I make changes. | ||
| 354 | |||
| 355 | =head1 SUPPORT | ||
| 356 | |||
| 357 | You can find documentation for this module with the perldoc command. | ||
| 358 | |||
| 359 | perldoc AnyEvent::XMPP | ||
| 360 | |||
| 361 | You can also look for information at: | ||
| 362 | |||
| 363 | =over 4 | ||
| 364 | |||
| 365 | =item * IRC: AnyEvent::XMPP IRC Channel | ||
| 366 | |||
| 367 | IRC Network: http://freenode.net/ | ||
| 368 | Server : chat.freenode.net | ||
| 369 | Channel : #ae_xmpp | ||
| 370 | |||
| 371 | Feel free to join and ask questions! | ||
| 372 | |||
| 373 | =item * AnyEvent::XMPP Project Site | ||
| 374 | |||
| 375 | L<http://www.ta-sa.org/net_xmpp2> | ||
| 376 | |||
| 377 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 378 | |||
| 379 | L<http://annocpan.org/dist/AnyEvent-XMPP> | ||
| 380 | |||
| 381 | =item * CPAN Ratings | ||
| 382 | |||
| 383 | L<http://cpanratings.perl.org/d/AnyEvent-XMPP> | ||
| 384 | |||
| 385 | =item * RT: CPAN's request tracker | ||
| 386 | |||
| 387 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-XMPP> | ||
| 388 | |||
| 389 | =item * Search CPAN | ||
| 390 | |||
| 391 | L<http://search.cpan.org/dist/AnyEvent-XMPP> | ||
| 392 | |||
| 393 | =back | ||
| 394 | |||
| 395 | =head1 ACKNOWLEDGEMENTS | ||
| 396 | |||
| 397 | Thanks to the XSF for the development of an open instant messaging protocol (even though it uses "XML"). | ||
| 398 | |||
| 399 | And thanks to all people who had to listen to my desperate curses about the | ||
| 400 | brokenness/braindeadness of XMPP. Without you I would've never brought this | ||
| 401 | module to a usable state. | ||
| 402 | |||
| 403 | Thanks to: | ||
| 404 | |||
| 405 | =over 4 | ||
| 406 | |||
| 407 | =item * J. Cameijo Cerdeira | ||
| 408 | |||
| 409 | For pointing out a serious bug in C<split_jid> in L<AnyEvent::XMPP::Util> | ||
| 410 | and suggesting to add a timeout argument to the C<connect> method of | ||
| 411 | L<AnyEvent::XMPP::SimpleConnection>. | ||
| 412 | |||
| 413 | =item * Carlo von Loesch (aka lynX) L<http://www.psyced.org/> | ||
| 414 | |||
| 415 | For pointing out some typos. | ||
| 416 | |||
| 417 | =item * All other people .. | ||
| 418 | |||
| 419 | ... I mentioned in the CONTRIBUTORS file which comes with the L<AnyEvent::XMPP> | ||
| 420 | distribution. | ||
| 421 | |||
| 422 | =back | ||
| 423 | |||
| 424 | =head1 COPYRIGHT & LICENSE | ||
| 425 | |||
| 426 | Copyright 2007, 2008 Robin Redeker, all rights reserved. | ||
| 427 | |||
| 428 | This program is free software; you can redistribute it and/or modify it | ||
| 429 | under the same terms as Perl itself. | ||
| 430 | |||
| 431 | =cut | ||
| 432 | |||
| 433 | 6 | 1; # End of AnyEvent::XMPP | |