File Coverage

blib/lib/Protocol/XMPP/Contact.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 2 0.0
condition n/a
subroutine 3 9 33.3
pod 4 6 66.6
total 16 37 43.2


line stmt bran cond sub pod time code
1             package Protocol::XMPP::Contact;
2              
3 2     2   216405 use strict;
  2         23  
  2         955  
4 2     2   15 use warnings;
  2         4  
  2         204  
5 2     2   13 use parent qw{Protocol::XMPP::Base};
  2         4  
  2         18  
6              
7             our $VERSION = '0.007'; ## VERSION
8              
9             =head1 NAME
10              
11             Protocol::XMPP::Stream - handle XMPP protocol stream
12              
13             =head1 METHODS
14              
15             =cut
16              
17 0     0 0   sub jid { shift->{jid} }
18 0 0   0 1   sub name { my $self = shift; defined($self->{name}) ? $self->{name} : $self->{jid} }
  0            
19              
20             sub is_me {
21 0     0 0   my $self = shift;
22 0           return $self->jid eq $self->stream->jid;
23             }
24              
25             =head2 authorise
26              
27             Authorise a contact by sending a 'subscribed' presence response.
28              
29             =cut
30              
31             sub authorise {
32 0     0 1   my $self = shift;
33 0           $self->write_xml(['presence', from => $self->stream->jid, to => $self->jid, type => 'subscribed']);
34             }
35              
36             =head2 subscribe
37              
38             Request subscription for a contact by sending a 'subscribe' presence response.
39              
40             =cut
41              
42             sub subscribe {
43 0     0 1   my $self = shift;
44 0           $self->write_xml(['presence', from => $self->stream->jid, to => $self->jid, type => 'subscribe']);
45             }
46              
47             =head2 unsubscribe
48              
49             Reject or unsubscribe a contact by sending an 'unsubscribed' presence response.
50              
51             =cut
52              
53             sub unsubscribe {
54 0     0 1   my $self = shift;
55 0           $self->write_xml(['presence', from => $self->stream->jid, to => $self->jid, type => 'unsubscribed']);
56             }
57              
58             1;
59              
60             __END__