| 1 | package DJabberd::RosterStorage::InMemoryOnly; | ||||||||||
| 2 | |||||||||||
| 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::RosterStorage'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 17 | ▶ | use DJabberd::Log; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 17 | ▶ | use DJabberd::RosterItem; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 17 | our $logger = DJabberd::Log->get_logger(); | |||||||||
| 10 | |||||||||||
| 11 | sub finalize { | ||||||||||
| 12 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
finalize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 13 | |||||||||||
| 14 | 0 | $self->{rosters} = {}; | |||||||||
| 15 | # 'user@local' => { | ||||||||||
| 16 | # 'contact@remote' => { rosteritem attribs }, | ||||||||||
| 17 | # ... | ||||||||||
| 18 | # } | ||||||||||
| 19 | |||||||||||
| 20 | 0 | return $self; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub blocking { 0 } | ||||||||
|
Subroutine
blocking: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 24 | |||||||||||
| 25 | sub get_roster { | ||||||||||
| 26 | 0 | ▶ | my ($self, $cb, $jid) = @_; | ||||||||
|
Subroutine
get_roster: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 27 | 0 | my $jidstr = $jid->as_bare_string; | |||||||||
| 28 | |||||||||||
| 29 | 0 | $logger->debug("Getting roster for '$jid'"); | |||||||||
| 30 | |||||||||||
| 31 | 0 | my $roster = DJabberd::Roster->new; | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | foreach my $item (values %{$self->{rosters}->{$jidstr} || {}}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | my $subscription = DJabberd::Subscription->from_bitmask($item->{subscription}); | |||||||||
| 35 | 0 | $roster->add(DJabberd::RosterItem->new(%$item, subscription => $subscription)); | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | $logger->debug(" ... got groups, calling set_roster.."); | |||||||||
| 39 | |||||||||||
| 40 | 0 | $cb->set_roster($roster); | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | sub set_roster_item { | ||||||||||
| 44 | 0 | ▶ | my ($self, $cb, $jid, $ritem) = @_; | ||||||||
|
Subroutine
set_roster_item: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 0 | my $jidstr = $jid->as_bare_string; | |||||||||
| 46 | 0 | my $rjidstr = $ritem->jid->as_bare_string; | |||||||||
| 47 | |||||||||||
| 48 | 0 | $self->{rosters}->{$jidstr}->{$rjidstr} = { | |||||||||
| 49 | jid => $rjidstr, | ||||||||||
| 50 | name => $ritem->name, | ||||||||||
| 51 | groups => [$ritem->groups], | ||||||||||
| 52 | subscription => $ritem->subscription->as_bitmask, | ||||||||||
| 53 | }; | ||||||||||
| 54 | |||||||||||
| 55 | 0 | $logger->debug("Set roster item"); | |||||||||
| 56 | 0 | $cb->done($ritem); | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | sub addupdate_roster_item { | ||||||||||
| 60 | 0 | ▶ | my ($self, $cb, $jid, $ritem) = @_; | ||||||||
|
Subroutine
addupdate_roster_item: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 61 | 0 | my $jidstr = $jid->as_bare_string; | |||||||||
| 62 | 0 | my $rjidstr = $ritem->jid->as_bare_string; | |||||||||
| 63 | |||||||||||
| 64 | 0 | my $olditem = $self->{rosters}->{$jidstr}->{$rjidstr}; | |||||||||
| 65 | |||||||||||
| 66 | 0 | my $newitem = $self->{rosters}->{$jidstr}->{$rjidstr} = { | |||||||||
| 67 | jid => $rjidstr, | ||||||||||
| 68 | name => $ritem->name, | ||||||||||
| 69 | groups => [$ritem->groups], | ||||||||||
| 70 | }; | ||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | if (defined $olditem) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 0 | $ritem->set_subscription(DJabberd::Subscription->from_bitmask($olditem->{subscription})); | |||||||||
| 74 | 0 | $newitem->{subscription} = $olditem->{subscription}; | |||||||||
| 75 | } | ||||||||||
| 76 | else { | ||||||||||
| 77 | 0 | $newitem->{subscription} = $ritem->subscription->as_bitmask; | |||||||||
| 78 | } | ||||||||||
| 79 | |||||||||||
| 80 | 0 | $cb->done($ritem); | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | sub delete_roster_item { | ||||||||||
| 84 | 0 | ▶ | my ($self, $cb, $jid, $ritem) = @_; | ||||||||
|
Subroutine
delete_roster_item: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 85 | 0 | $logger->debug("delete roster item!"); | |||||||||
| 86 | |||||||||||
| 87 | 0 | my $jidstr = $jid->as_bare_string; | |||||||||
| 88 | 0 | my $rjidstr = $ritem->jid->as_bare_string; | |||||||||
| 89 | |||||||||||
| 90 | 0 | delete $self->{rosters}->{$jidstr}->{$rjidstr}; | |||||||||
| 91 | |||||||||||
| 92 | 0 | $cb->done; | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | sub load_roster_item { | ||||||||||
| 96 | 0 | ▶ | my ($self, $jid, $contact_jid, $cb) = @_; | ||||||||
|
Subroutine
load_roster_item: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 97 | |||||||||||
| 98 | 0 | my $jidstr = $jid->as_bare_string; | |||||||||
| 99 | 0 | my $cjidstr = $contact_jid->as_bare_string; | |||||||||
| 100 | |||||||||||
| 101 | 0 | my $options = $self->{rosters}->{$jidstr}->{$cjidstr}; | |||||||||
| 102 | |||||||||||
| 103 | 0 | ▶ | unless (defined $options) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 104 | 0 | $cb->set(undef); | |||||||||
| 105 | 0 | return; | |||||||||
| 106 | } | ||||||||||
| 107 | |||||||||||
| 108 | 0 | my $subscription = DJabberd::Subscription->from_bitmask($options->{subscription}); | |||||||||
| 109 | |||||||||||
| 110 | 0 | my $item = DJabberd::RosterItem->new(%$options, subscription => $subscription); | |||||||||
| 111 | |||||||||||
| 112 | 0 | $cb->set($item); | |||||||||
| 113 | 0 | return; | |||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | sub wipe_roster { | ||||||||||
| 117 | 0 | ▶ | my ($self, $cb, $jid) = @_; | ||||||||
|
Subroutine
wipe_roster: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 118 | |||||||||||
| 119 | 0 | my $jidstr = $jid->as_bare_string; | |||||||||
| 120 | |||||||||||
| 121 | 0 | delete $self->{rosters}->{$jidstr}; | |||||||||
| 122 | |||||||||||
| 123 | 0 | $cb->done; | |||||||||
| 124 | } | ||||||||||
| 125 | |||||||||||
| 126 | 17 | 1; | |||||||||