ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-XMPP2/lib/Net/XMPP2/Ext/Disco/Items.pm
Revision: 1.4
Committed: Thu Jul 12 07:28:24 2007 UTC (19 years, 3 months ago) by elmex
Branch: MAIN
Changes since 1.3: +0 -1 lines
Log Message:
minor doc fixes and i should put some stuff in the synopsises sometime

File Contents

# User Rev Content
1 elmex 1.2 package Net::XMPP2::Ext::Disco::Items;
2 elmex 1.1 use Net::XMPP2::Namespaces qw/xmpp_ns/;
3    
4     =head1 NAME
5    
6 elmex 1.2 Net::XMPP2::Ext::Disco::Items - Service discovery items
7 elmex 1.1
8     =head1 SYNOPSIS
9    
10     =head1 DESCRIPTION
11    
12     This class represents the result of a disco items request
13 elmex 1.2 sent by a C<Net::XMPP2::Ext::Disco> handler.
14 elmex 1.1
15     =head1 METHODS
16    
17 elmex 1.3 =over 4
18    
19 elmex 1.1 =cut
20    
21     sub new {
22     my $this = shift;
23     my $class = ref($this) || $this;
24     my $self = bless { @_ }, $class;
25     $self->init;
26     $self
27     }
28    
29 elmex 1.3 =item B<xml_node ()>
30 elmex 1.1
31     Returns the L<Net::XMPP2::Node> object of the IQ query.
32    
33     =cut
34    
35     sub xml_node {
36     my ($self) = @_;
37     $self->{xmlnode}
38     }
39    
40     sub init {
41     my ($self) = @_;
42     my $node = $self->{xmlnode};
43    
44     my (@items) = $node->find_all ([qw/disco_items item/]);
45     for (@items) {
46     push @{$self->{items}}, {
47     jid => $_->attr ('jid'),
48     name => $_->attr ('name'),
49     node => $_->attr ('node'),
50     xml_node => $_,
51     };
52     }
53     }
54    
55 elmex 1.3 =item B<jid ()>
56 elmex 1.1
57     Returns the JID these items belong to.
58    
59     =cut
60    
61     sub jid { $_[0]->{jid} }
62    
63 elmex 1.3 =item B<node ()>
64 elmex 1.1
65     Returns the node these items belong to (may be undef).
66    
67     =cut
68    
69     sub node { $_[0]->{node} }
70    
71 elmex 1.3 =item B<items ()>
72 elmex 1.1
73     Returns a list of hashreferences which contain following keys:
74    
75     jid, name, node and xml_node
76    
77     C<jid> contains the JID of the item.
78     C<name> contains the name of the item and might be undef.
79     C<node> contains the node id of the item and might be undef.
80     C<xml_node> contains the L<Net::XMPP2::Node> object of the item
81     for further analyses.
82    
83     =cut
84    
85     sub items {
86     my ($self) = @_;
87     @{$self->{items}}
88     }
89    
90 elmex 1.3 =item B<debug_dump ()>
91 elmex 1.1
92     Prints these items to stdout for debugging.
93    
94     =cut
95    
96     sub debug_dump {
97     my ($self) = @_;
98     printf "ITEMS FOR %s (%s):\n", $self->jid, $self->node;
99     for ($self->items) {
100     printf " - %-40s (%30s): %s\n", $_->{jid}, $_->{node}, $_->{name}
101     }
102     print "END ITEMS\n";
103     }
104    
105 elmex 1.3 =back
106    
107 elmex 1.1 =head1 AUTHOR
108    
109 elmex 1.3 Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
110 elmex 1.1
111     =head1 COPYRIGHT & LICENSE
112    
113     Copyright 2007 Robin Redeker, all rights reserved.
114    
115     This program is free software; you can redistribute it and/or modify it
116     under the same terms as Perl itself.
117    
118     =cut
119    
120     1;