DJabberd/RosterStorage.pm

filter: Statementstmt 50.9% 27 / 53 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 35.0% 7 / 20 Podpod 0.0% 0 / 9 totaltotal 41.4% 34 / 82 CC 1 SCAR 5.1
CC
1
Cov
51%
singleton
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.7
« DJabberd/Plugin.pm ↑ Summary DJabberd/PresenceChecker.pm »
1 package DJabberd::RosterStorage;
2 # abstract base class
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use base 'DJabberd::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use DJabberd::Roster;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use DJabberd::RosterItem;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 ### store the object in a closure, so we can retrieve it later
10 ### this allows us to manipulate the roster storage from other
11 ### places, to for example pre-link users.
12 17 { my $singleton;
13 0 ▶ sub singleton { $singleton };
Subroutine singleton: not called CC=1 SCAR=6.9
Pod undocumented
14
15 sub new {
16 37 ▶ my $self = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
17 37 $singleton = $self->SUPER::new( @_ );
18 }
19 }
20  
21 # don't override, or at least call SUPER to this if you do.
22 17 sub register {
23 37 ▶ my ($self, $vhost) = @_;
Subroutine register: called CC=1 SCAR=2.2
Pod undocumented
24 $vhost->register_hook("RosterGet", sub {
25 0 ▶ my ($vh, $cb, $jid) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 # cb can '->set_roster(Roster)' or decline
27 0 $self->get_roster($cb, $jid);
28 37 });
29 $vhost->register_hook("RosterAddUpdateItem", sub {
30 0 ▶ my ($vh, $cb, $jid, $ritem) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 # $cb takes ->done($ritem_final) or error
32 0 $self->addupdate_roster_item($cb, $jid, $ritem);
33 37 });
34 $vhost->register_hook("RosterRemoveItem", sub {
35 0 ▶ my ($vh, $cb, $jid, $ritem) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 # $cb can ->done
37 0 $self->delete_roster_item($cb, $jid, $ritem);
38 37 });
39 $vhost->register_hook("RosterLoadItem", sub {
40 0 ▶ my ($vh, $cb, $user_jid, $contact_jid) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 # cb can 'set($data|undef)' and 'error($reason)'
42 0 $self->load_roster_item($user_jid, $contact_jid, $cb);
43 37 });
44  
45 $vhost->register_hook("RosterSetItem", sub {
46 0 ▶ my ($vh, $cb, $user_jid, $ritem) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 # cb can ->error($reason) and ->done()
48 0 $self->set_roster_item($cb, $user_jid, $ritem);
49 37 });
50 $vhost->register_hook("RosterWipe", sub {
51 0 ▶ my ($vh, $cb, $user_jid) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 # cb can ->error($reason) and ->done()
53 0 $self->wipe_roster($cb, $user_jid);
54 37 });
55  
56 }
57  
58 # override this.
59 sub get_roster {
60 0 ▶ my ($self, $cb, $jid) = @_;
Subroutine get_roster: not called CC=1 SCAR=6.9
Pod undocumented
61 0 $cb->declined;
62 }
63  
64 # override this.
65 sub addupdate_roster_item {
66 0 ▶ my ($self, $cb, $jid, $ritem) = @_;
Subroutine addupdate_roster_item: not called CC=1 SCAR=6.9
Pod undocumented
67 0 $cb->declined;
68 }
69  
70 # override this. unlike addupdate, you should respect the subscription level
71 sub set_roster_item {
72 0 ▶ my ($self, $cb, $jid, $ritem) = @_;
Subroutine set_roster_item: not called CC=1 SCAR=6.9
Pod undocumented
73 0 warn "SET ROSTER ITEM FAILED\n";
74 0 $cb->error;
75 }
76  
77 # override this.
78 sub delete_roster_item {
79 0 ▶ my ($self, $cb, $jid, $ritem) = @_;
Subroutine delete_roster_item: not called CC=1 SCAR=6.9
Pod undocumented
80 0 $cb->declined;
81 }
82  
83 # override this.
84 sub load_roster_item {
85 0 ▶ my ($self, $jid, $target_jid, $cb) = @_;
Subroutine load_roster_item: not called CC=1 SCAR=6.9
Pod undocumented
86 0 $cb->error("load_roster_item not implemented");
87 }
88  
89 # override this.
90 sub wipe_roster {
91 0 ▶ my ($self, $cb, $jid) = @_;
Subroutine wipe_roster: not called CC=1 SCAR=6.9
Pod undocumented
92 0 $cb->error("wipe_roster not implemented");
93 }
94  
95 17 1;
« DJabberd/Plugin.pm ↑ Summary DJabberd/PresenceChecker.pm »