package AnyEvent::XMPP::Ext::Disco::Items; use AnyEvent::XMPP::Namespaces qw/xmpp_ns/; use strict; =head1 NAME AnyEvent::XMPP::Ext::Disco::Items - Service discovery items =head1 SYNOPSIS =head1 DESCRIPTION This class represents the result of a disco items request sent by a C handler. =head1 METHODS =over 4 =cut sub new { my $this = shift; my $class = ref($this) || $this; my $self = bless { @_ }, $class; $self->init; $self } =item B Returns the L object of the IQ query. =cut sub xml_node { my ($self) = @_; $self->{xmlnode} } sub init { my ($self) = @_; my $node = $self->{xmlnode}; return unless $node; my (@items) = $node->find_all ([qw/disco_items item/]); for (@items) { push @{$self->{items}}, { jid => $_->attr ('jid'), name => $_->attr ('name'), node => $_->attr ('node'), xml_node => $_, }; } } =item B Returns the JID these items belong to. =cut sub jid { $_[0]->{jid} } =item B Returns the node these items belong to (may be undef). =cut sub node { $_[0]->{node} } =item B Returns a list of hashreferences which contain following keys: jid, name, node and xml_node C contains the JID of the item. C contains the name of the item and might be undef. C contains the node id of the item and might be undef. C contains the L object of the item for further analyses. =cut sub items { my ($self) = @_; @{$self->{items}} } =item B Prints these items to stdout for debugging. =cut sub debug_dump { my ($self) = @_; printf "ITEMS FOR %s (%s):\n", $self->jid, $self->node; for ($self->items) { printf " - %-40s (%30s): %s\n", $_->{jid}, $_->{node}, $_->{name} } print "END ITEMS\n"; } =back =head1 AUTHOR Robin Redeker, C<< >>, JID: C<< >> =head1 COPYRIGHT & LICENSE Copyright 2007, 2008 Robin Redeker, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1;