ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-XMPP2/lib/Net/XMPP2/Ext/Disco/Items.pm
Revision: 1.5
Committed: Sun Jul 15 15:11:32 2007 UTC (19 years, 3 months ago) by elmex
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -0 lines
Log Message:
fixed minor issue with disco

File Contents

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