ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Net-XMPP2/lib/Net/XMPP2/Ext/Disco/Info.pm
Revision: 1.4
Committed: Thu Jul 12 07:28:24 2007 UTC (19 years, 4 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::Info;
2 elmex 1.1 use Net::XMPP2::Namespaces qw/xmpp_ns/;
3    
4     =head1 NAME
5    
6 elmex 1.2 Net::XMPP2::Ext::Disco::Info - Service discovery items
7 elmex 1.1
8     =head1 SYNOPSIS
9    
10     =head1 DESCRIPTION
11    
12     This class represents the result of a disco info 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 elmex 1.3 =item B<jid ()>
41 elmex 1.1
42     Returns the JID these items belong to.
43    
44     =cut
45    
46     sub jid { $_[0]->{jid} }
47    
48 elmex 1.3 =item B<node ()>
49 elmex 1.1
50     Returns the node these items belong to (may be undef).
51    
52     =cut
53    
54     sub node { $_[0]->{node} }
55    
56     sub init {
57     my ($self) = @_;
58     my $node = $self->{xmlnode};
59    
60     my (@ids) = $node->find_all ([qw/disco_info identity/]);
61     for (@ids) {
62     push @{$self->{identities}}, {
63     category => $_->attr ('category'),
64     type => $_->attr ('type'),
65     name => $_->attr ('name'),
66     xml_node => $_,
67     };
68     }
69    
70     my (@fs) = $node->find_all ([qw/disco_info feature/]);
71     $self->{features}->{$_->attr ('var')} = $_ for @fs;
72    
73     }
74    
75 elmex 1.3 =item B<identities ()>
76 elmex 1.1
77     Returns a list of hashrefs which contain following keys:
78    
79     category, type, name, xml_node
80    
81     C<category> is the category of the identity. C<type> is the
82     type of the identity. C<name> is the human readable name of
83     the identity and might be undef. C<xml_node> is the L<Net::XMPP2::Node>
84     object of the <identity/> node.
85    
86     C<category> and C<type> may be one of those defined on:
87    
88     http://www.xmpp.org/registrar/disco-categories.html
89    
90     =cut
91    
92     sub identities {
93     my ($self) = @_;
94     @{$self->{identities}}
95     }
96    
97 elmex 1.3 =item B<features ()>
98 elmex 1.1
99     Returns a hashref of key/value pairs where the key is the feature name
100     as listed on:
101    
102     http://www.xmpp.org/registrar/disco-features.html
103    
104     and the value is a L<Net::XMPP2::Node> object for the <feature/> node.
105    
106     =cut
107    
108     sub features { $_[0]->{features} || {} }
109    
110    
111 elmex 1.3 =item B<debug_dump ()>
112 elmex 1.1
113     Prints the information of this Info object to stdout.
114    
115     =cut
116    
117     sub debug_dump {
118     my ($self) = @_;
119     printf "INFO FOR %s (%s):\n", $self->jid, $self->node;
120     for ($self->identities) {
121     printf " ID : %20s/%-10s (%s)\n", $_->{category}, $_->{type}, $_->{name}
122     }
123     for (sort keys %{$self->features}) {
124     printf " FEATURE: %s\n", $_;
125     }
126 elmex 1.3 print "END ITEMS\n";
127 elmex 1.1
128     }
129    
130 elmex 1.3 =back
131    
132 elmex 1.1 =head1 AUTHOR
133    
134 elmex 1.3 Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >>
135 elmex 1.1
136     =head1 COPYRIGHT & LICENSE
137    
138     Copyright 2007 Robin Redeker, all rights reserved.
139    
140     This program is free software; you can redistribute it and/or modify it
141     under the same terms as Perl itself.
142    
143     =cut
144    
145     1;