| 1 | package DJabberd::PresenceChecker; | ||
| 2 | # abstract base class | ||
| 3 | 20 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 20 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 20 | ▶ | use base 'DJabberd::Plugin'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 43 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 8 | 43 | my ($class) = @_; | |
| 9 | 43 | return bless {}, $class; | |
| 10 | } | ||
| 11 | |||
| 12 | 0 | ▶ | sub vhost { $_[0]->{vhost} } |
|
Subroutine
vhost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 13 | |||
| 14 | 43 | ▶ | sub register { |
|
Subroutine
register: called CC=1 SCAR=2.0
Pod
undocumented
| |||
| 15 | 43 | my ($self, $vhost) = @_; | |
| 16 | |||
| 17 | 43 | $self->{vhost} = $vhost; | |
| 18 | 43 | Scalar::Util::weaken($self->{vhost}); | |
| 19 | |||
| 20 | # this is an odd hook, in that it wants to be called a lot, but the | ||
| 21 | # normal hook chain system doesn't support that, so instead | ||
| 22 | # this provides a cleaner interface for subclasses, which just call | ||
| 23 | # 'add' and 'done', and this takes care of the ugliness of calling | ||
| 24 | # the $add_cb callback. | ||
| 25 | 0 | ▶ | $vhost->register_hook("PresenceCheck", sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 26 | 0 | my (undef, $cb, $jid, $add_cb) = @_; | |
| 27 | # cb can 'decline' only | ||
| 28 | |||
| 29 | my $cb2 = DJabberd::Callback->new({ | ||
| 30 | 0 | ▶ | done => sub { $cb->decline }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 31 | 0 | ▶ | decline => sub { $cb->decline }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 32 | 0 | ▶ | declined => sub { $cb->decline }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 33 | 0 | }); | |
| 34 | |||
| 35 | 0 | $self->check_presence($cb2, $jid, $add_cb); | |
| 36 | |||
| 37 | 43 | }); | |
| 38 | } | ||
| 39 | |||
| 40 | # override this. | ||
| 41 | 0 | ▶ | sub check_presence { |
|
Subroutine
check_presence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 42 | 0 | my ($self, $cb, $jid, $add_cb) = @_; | |
| 43 | # cb can only '->done/decline' | ||
| 44 | 0 | $cb->done; | |
| 45 | } | ||
| 46 | |||
| 47 | 20 | 1; | |