| 1 | package AnyEvent::XMPP::Ext::Disco::Info; | ||||||||||||||||||||
| 2 | 1 | ▶ | use AnyEvent::XMPP::Namespaces qw/xmpp_ns/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | AnyEvent::XMPP::Ext::Disco::Info - Service discovery info | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | This class represents the result of a disco info request | ||||||||||||||||||||
| 14 | sent by a C<AnyEvent::XMPP::Ext::Disco> handler. | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head1 METHODS | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | =over 4 | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 23 | 0 | my $this = shift; | |||||||||||||||||||
| 24 | 0 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||
|
Condition0%0/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table0%0/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||
| 25 | 0 | my $self = bless { @_ }, $class; | |||||||||||||||||||
| 26 | 0 | $self->init; | |||||||||||||||||||
| 27 | 0 | $self | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =item B<xml_node ()> | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | Returns the L<AnyEvent::XMPP::Node> object of the IQ query. | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub xml_node { | ||||||||||||||||||
|
Subroutine
xml_node: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 37 | 0 | my ($self) = @_; | |||||||||||||||||||
| 38 | $self->{xmlnode} | ||||||||||||||||||||
| 39 | 0 | } | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =item B<jid ()> | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | Returns the JID these items belong to. | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub jid { $_[0]->{jid} } | ||||||||||||||||||
|
Subroutine
jid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =item B<node ()> | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | Returns the node these items belong to (may be undef). | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | ▶ | sub node { $_[0]->{node} } | ||||||||||||||||||
|
Subroutine
node: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 58 | 0 | my ($self) = @_; | |||||||||||||||||||
| 59 | 0 | my $node = $self->{xmlnode}; | |||||||||||||||||||
| 60 | 0 | ▶ | return unless $node; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | my (@ids) = $node->find_all ([qw/disco_info identity/]); | |||||||||||||||||||
| 63 | 0 | for (@ids) { | |||||||||||||||||||
| 64 | 0 | push @{$self->{identities}}, { | |||||||||||||||||||
| 65 | category => $_->attr ('category'), | ||||||||||||||||||||
| 66 | type => $_->attr ('type'), | ||||||||||||||||||||
| 67 | name => $_->attr ('name'), | ||||||||||||||||||||
| 68 | xml_node => $_, | ||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | my (@fs) = $node->find_all ([qw/disco_info feature/]); | |||||||||||||||||||
| 73 | 0 | $self->{features}->{$_->attr ('var')} = $_ for @fs; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =item B<identities ()> | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | Returns a list of hashrefs which contain following keys: | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | category, type, name, xml_node | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | C<category> is the category of the identity. C<type> is the | ||||||||||||||||||||
| 84 | type of the identity. C<name> is the human readable name of | ||||||||||||||||||||
| 85 | the identity and might be undef. C<xml_node> is the L<AnyEvent::XMPP::Node> | ||||||||||||||||||||
| 86 | object of the <identity/> node. | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | C<category> and C<type> may be one of those defined on: | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | http://www.xmpp.org/registrar/disco-categories.html | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | ▶ | sub identities { | ||||||||||||||||||
|
Subroutine
identities: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 95 | 0 | my ($self) = @_; | |||||||||||||||||||
| 96 | 0 | @{$self->{identities}} | |||||||||||||||||||
| 97 | } | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | =item B<features ()> | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | Returns a hashref of key/value pairs where the key is the feature name | ||||||||||||||||||||
| 102 | as listed on: | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | http://www.xmpp.org/registrar/disco-features.html | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | and the value is a L<AnyEvent::XMPP::Node> object for the <feature/> node. | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 0 | ▶ | sub features { $_[0]->{features} || {} } | ||||||||||||||||||
|
Subroutine
features: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | =item B<debug_dump ()> | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | Prints the information of this Info object to stdout. | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | =cut | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 0 | ▶ | sub debug_dump { | ||||||||||||||||||
|
Subroutine
debug_dump: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 120 | 0 | my ($self) = @_; | |||||||||||||||||||
| 121 | 0 | printf "INFO FOR %s (%s):\n", $self->jid, $self->node; | |||||||||||||||||||
| 122 | 0 | for ($self->identities) { | |||||||||||||||||||
| 123 | printf " ID : %20s/%-10s (%s)\n", $_->{category}, $_->{type}, $_->{name} | ||||||||||||||||||||
| 124 | 0 | } | |||||||||||||||||||
| 125 | 0 | for (sort keys %{$self->features}) { | |||||||||||||||||||
| 126 | 0 | printf " FEATURE: %s\n", $_; | |||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | 0 | print "END ITEMS\n"; | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | } | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | =back | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | =head1 AUTHOR | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | Robin Redeker, C<< <elmex at ta-sa.org> >>, JID: C<< <elmex at jabber.org> >> | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | Copyright 2007, 2008 Robin Redeker, all rights reserved. | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 143 | under the same terms as Perl itself. | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | =cut | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | 1 | 1; | |||||||||||||||||||