AnyEvent::XMPP::Ext::Disco::Info - Service discovery info


AnyEvent-XMPP documentation Contained in the AnyEvent-XMPP distribution.

Index


Code Index:

NAME

Top

AnyEvent::XMPP::Ext::Disco::Info - Service discovery info

SYNOPSIS

Top

DESCRIPTION

Top

This class represents the result of a disco info request sent by a AnyEvent::XMPP::Ext::Disco handler.

METHODS

Top

xml_node ()

Returns the AnyEvent::XMPP::Node object of the IQ query.

jid ()

Returns the JID these items belong to.

node ()

Returns the node these items belong to (may be undef).

identities ()

Returns a list of hashrefs which contain following keys:

   category, type, name, xml_node

category is the category of the identity. type is the type of the identity. name is the human readable name of the identity and might be undef. xml_node is the AnyEvent::XMPP::Node object of the <identity/> node.

category and type may be one of those defined on:

   http://www.xmpp.org/registrar/disco-categories.html

features ()

Returns a hashref of key/value pairs where the key is the feature name as listed on:

   http://www.xmpp.org/registrar/disco-features.html

and the value is a AnyEvent::XMPP::Node object for the <feature/> node.

debug_dump ()

Prints the information of this Info object to stdout.

AUTHOR

Top

Robin Redeker, <elmex at ta-sa.org>, JID: <elmex at jabber.org>

COPYRIGHT & LICENSE

Top


AnyEvent-XMPP documentation Contained in the AnyEvent-XMPP distribution.
package AnyEvent::XMPP::Ext::Disco::Info;
use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
use strict;

sub new {
   my $this = shift;
   my $class = ref($this) || $this;
   my $self = bless { @_ }, $class;
   $self->init;
   $self
}

sub xml_node {
   my ($self) = @_;
   $self->{xmlnode}
}

sub jid { $_[0]->{jid} }

sub node { $_[0]->{node} }

sub init {
   my ($self) = @_;
   my $node = $self->{xmlnode};
   return unless $node;

   my (@ids) = $node->find_all ([qw/disco_info identity/]);
   for (@ids) {
      push @{$self->{identities}}, {
         category => $_->attr ('category'),
         type     => $_->attr ('type'),
         name     => $_->attr ('name'),
         xml_node => $_,
      };
   }

   my (@fs) = $node->find_all ([qw/disco_info feature/]);
   $self->{features}->{$_->attr ('var')} = $_ for @fs;

}

sub identities {
   my ($self) = @_;
   @{$self->{identities}}
}

sub features { $_[0]->{features} || {} }


sub debug_dump {
   my ($self) = @_;
   printf "INFO FOR %s (%s):\n", $self->jid, $self->node;
   for ($self->identities) {
      printf "   ID     : %20s/%-10s (%s)\n", $_->{category}, $_->{type}, $_->{name}
   }
   for (sort keys %{$self->features}) {
      printf "   FEATURE: %s\n", $_;
   }
   print "END ITEMS\n";

}

1;