/usr/share/barnowl/lib/BarnOwl/MainLoopCompatHook.pm is in barnowl 1.9-4build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | use strict;
use warnings;
package BarnOwl::MainLoopCompatHook;
use BarnOwl;
use BarnOwl::Hook;
use BarnOwl::Timer;
use Scalar::Util qw(weaken);
sub new {
my $class = shift;
my $hook = BarnOwl::Hook->new;
return bless {hook => $hook}, $class;
}
sub check_owlconf {
my $self = shift;
$self->_ensure_timer() if (*BarnOwl::mainloop_hook{CODE});
}
sub run {
my $self = shift;
return $self->{hook}->run(@_);
}
sub add {
my $self = shift;
$self->_ensure_timer();
$self->{hook}->add(@_);
}
sub clear {
my $self = shift;
$self->_kill_timer() unless *BarnOwl::mainloop_hook{CODE};
$self->{hook}->clear();
}
sub _ensure_timer {
my $self = shift;
BarnOwl::debug("Enabling backwards-compatibility \"main loop\" hook");
my $weak = $self;
weaken($weak);
unless ($self->{timer}) {
$self->{timer} = BarnOwl::Timer->new( {
name => "BarnOwl::MainLoopCompatHook",
after => 0,
interval => 1,
cb => sub {
$weak->run if $weak;
BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE};
},
} );
}
}
sub _kill_timer {
my $self = shift;
if ($self->{timer}) {
$self->{timer}->stop;
undef $self->{timer};
}
}
1;
|