line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of POE-Component-ICal |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is copyright (c) 2011 by Loïc TROCHET. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
7
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
package POE::Component::ICal; |
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
$POE::Component::ICal::VERSION = '0.130020'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
# ABSTRACT: Schedule POE events using rfc2445 recurrences |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
424714
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
104
|
|
16
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
98
|
|
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
17
|
use Carp qw(croak); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
169
|
|
19
|
3
|
|
|
3
|
|
6960
|
use DateTime; |
|
3
|
|
|
|
|
568548
|
|
|
3
|
|
|
|
|
117
|
|
20
|
3
|
|
|
3
|
|
3058
|
use DateTime::Event::ICal; |
|
3
|
|
|
|
|
184989
|
|
|
3
|
|
|
|
|
153
|
|
21
|
3
|
|
|
3
|
|
1644
|
use POE::Kernel; |
|
3
|
|
|
|
|
61270
|
|
|
3
|
|
|
|
|
37
|
|
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
97823
|
use POE::Component::Schedule; |
|
3
|
|
|
|
|
12555
|
|
|
3
|
|
|
|
|
92
|
|
24
|
3
|
|
|
3
|
|
65
|
use base qw(POE::Component::Schedule); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1250
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $_schedules = {}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub verify |
30
|
|
|
|
|
|
|
{ |
31
|
3
|
|
|
3
|
1
|
7
|
my ($class, $ical) = @_; |
32
|
|
|
|
|
|
|
|
33
|
3
|
50
|
|
|
|
10
|
if (defined wantarray) |
34
|
|
|
|
|
|
|
{ |
35
|
3
|
|
|
|
|
5
|
my $set; |
36
|
3
|
|
|
|
|
6
|
eval { $set = DateTime::Event::ICal->recur(%$ical); }; |
|
3
|
|
|
|
|
29
|
|
37
|
3
|
|
|
|
|
3697
|
my $is_valid = not $@; |
38
|
3
|
50
|
|
|
|
27
|
return wantarray ? ($is_valid, $is_valid ? $set : $@) : $is_valid; |
|
|
50
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
DateTime::Event::ICal->recur(%$ical); |
42
|
0
|
|
|
|
|
0
|
return 1; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub add_schedule |
47
|
|
|
|
|
|
|
{ |
48
|
3
|
|
|
3
|
1
|
1613
|
my ($class, $shedule, $event, $ical, @args) = @_; |
49
|
|
|
|
|
|
|
|
50
|
3
|
50
|
|
|
|
51
|
$ical->{dtstart} = DateTime->now unless exists $ical->{dtstart}; |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
1034
|
my ($is_valid, $value) = $class->verify($ical); |
53
|
3
|
50
|
|
|
|
15
|
croak $value unless $is_valid; |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
22
|
my $session = POE::Kernel->get_active_session; |
56
|
3
|
|
|
|
|
38
|
return $_schedules->{$session->ID}->{$shedule} = $class->SUPER::add($session, $event => $value, @args); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub add |
61
|
|
|
|
|
|
|
{ |
62
|
1
|
|
|
1
|
1
|
1201
|
my ($class, $event, $ical, @args) = @_; |
63
|
1
|
|
|
|
|
6
|
return $class->add_schedule($event, $event, $ical, @args); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub remove |
68
|
|
|
|
|
|
|
{ |
69
|
2
|
|
|
2
|
1
|
3640029
|
my ($class, $schedule) = @_; |
70
|
2
|
|
|
|
|
15
|
delete $_schedules->{POE::Kernel->get_active_session->ID}->{$schedule}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub remove_all |
75
|
|
|
|
|
|
|
{ |
76
|
1
|
|
|
1
|
1
|
3913297
|
delete $_schedules->{POE::Kernel->get_active_session->ID}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |