blib/lib/Schedule/Chronic/Constraint/InXs.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 54 CC 4 SCAR 13.9
CC
4
Cov
0%
init
6.0
met
6.0
wait
6.0
CRAP 4.0
1 ##
2 ## Detect System Inactivity or Xscreensaved Locking
3 ## Author: Vipul Ved Prakash <mail@vipul.net>.
4 ## $Id: InXs.pm,v 1.2 2004/07/15 21:11:07 hackworth Exp $
5 ##
6  
7 package Schedule::Chronic::Constraint::InXs;
8 use Schedule::Chronic::Base;
9 use Schedule::Chronic::Constraint::Inactivity;
10 use Schedule::Chronic::Constraint::Xscreensaver;
11 use base qw(Schedule::Chronic::Base);
12  
13  
14 sub new {
15  
16 my ($class) = @_;
17  
18 return bless {
19  
20 inactivity => new Schedule::Chronic::Constraint::Inactivity ($debug),
21 xscreensaver => new Schedule::Chronic::Constraint::Xscreensaver ($debug),
22  
23 }, shift
24  
25 }
26  
27  
28 sub init {
29  
30 my ($self, $schedule, $task, $logger, $active) = @_;
31 return unless ref $self;
32
33 $$self{inactivity}->init($schedule, $task, $logger, $active);
34 $$self{xscreensaver}->init($schedule, $task, $logger, $active);
35 $$self{logger} = $logger;
36  
37 return $self;
38  
39 }
40  
41  
42 sub met {
43  
44 my ($self) = @_;
45  
46 if ($self->{xscreensaver}->met() || $self->{inactivity}->met()) {
47 return 1;
48 } else {
49 return 0;
50 }
51  
52 }
53  
54  
55 sub state {
56  
57 # This is a "Container Constraint" that doesn't have a state of its
58 # own, so we return undef. This is an indication to the poller that
59 # the constraint doesn't have a state.
60  
61 return;
62  
63 }
64  
65  
66 sub wait {
67  
68 my $self = shift;
69 my $xs_wait = $self->{xscreensaver}->wait();
70 my $in_wait = $self->{inactivity}->wait();
71  
72 return $xs_wait > $in_wait ? $xs_wait : $in_wait;
73  
74 }
75  
76  
77 1;
78