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, 2 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

# 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 elmex 1.5 return unless $node;
44 elmex 1.1
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 elmex 1.3 =item B<jid ()>
57 elmex 1.1
58     Returns the JID these items belong to.
59    
60     =cut
61    
62     sub jid { $_[0]->{jid} }
63    
64 elmex 1.3 =item B<node ()>
65 elmex 1.1
66     Returns the node these items belong to (may be undef).
67    
68     =cut
69    
70     sub node { $_[0]->{node} }
71    
72 elmex 1.3 =item B<items ()>
73 elmex 1.1
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 elmex 1.3 =item B<debug_dump ()>
92 elmex 1.1
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 elmex 1.3 =back
107    
108 elmex 1.1 =head1 AUTHOR
109    
110 elmex 1.3 Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
111 elmex 1.1
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;