Limit the number of simultaneous connect attempts passed to libpurple.
[thrasher.git] / perl / lib / Thrasher / Plugin / PEP.pm
blobf8044fc4b37800b57baec169105c631aee2afc61
1 package Thrasher::Plugin::PEP;
2 use strict;
3 use warnings;
5 =pod
7 =head1 NAME
9 Thrasher::Plugin::PEP - adds PEP support to the virtual accounts,
10 allowing them to publish things in accordance with the PEP spec
12 =head1 DESCRIPTION
14 Thrasher::Plugin::PEP adds PEP support to your Component. The primary
15 manifestation is a function that you can use to publish things with
16 PEP.
18 At the moment, I'm not sure how to tell if the server supports PEP.
19 The standard says you're supposed to query
21 =cut
23 use Thrasher::Callbacks qw(:all);
24 use Thrasher::Constants qw(:all);
25 use Thrasher::Plugin::EntityCapabilities qw(:all);
27 use base 'Exporter';
29 our @EXPORT_OK = qw(pep_publish);
30 our %EXPORT_TAGS = (all => \@EXPORT_OK);
32 # use "do_when('pep_found')" for all major actions
34 sub detect_pep {
35 if (has_identity_category('pep')) {
36 succeeded('pep_detected');
37 } else {
38 failed('pep_detected');
42 do_when('server_capabilities_detected', \&detect_pep);
44 # Call this to publish something via PEP; nicely blocks on PEP being
45 # found
47 # If you get errors about "Can't use string ("SOME_NAMESPACE") as an
48 # ARRAY ref", your problem is that you need to add one more list
49 # around your $publish_xml; remember, you're providing the full
50 # children, not just one node.
51 sub pep_publish {
52 my $component = shift;
53 my $from_jid = shift;
54 my $publish_node_ns = shift;
55 my $publish_xml = shift;
57 do_when('pep_detected',
58 sub {
59 $component->iq_query
60 ([[$NS_COMPONENT, 'iq'],
61 {from => $from_jid,
62 type => 'set'},
64 [[$NS_PUBSUB, 'pubsub'], {},
66 [[$publish_node_ns, 'publish'], {},
67 $publish_xml
70 ]]);
71 });