| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
|
2
|
|
|
|
|
|
|
# -*- Mode: perl -*- |
|
3
|
|
|
|
|
|
|
#====================================================================== |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# This package is free software and is provided "as is" without |
|
6
|
|
|
|
|
|
|
# express or implied warranty. It may be used, redistributed and/or |
|
7
|
|
|
|
|
|
|
# modified under the same terms as perl itself. ( Either the Artistic |
|
8
|
|
|
|
|
|
|
# License or the GPL. ) |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# $Id: Trigger.pm,v 1.10 2001/06/30 20:42:06 lotr Exp $ |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# (C) COPYRIGHT 2000-2001, Reefknot developers. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# See the AUTHORS file included in the distribution for a full list. |
|
15
|
|
|
|
|
|
|
#====================================================================== |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Net::ICal::Trigger -- represent the TRIGGER property for VALARMs |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Net::ICal::Trigger; |
|
24
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
6
|
use base qw(Net::ICal::Property); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
655
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
857
|
use Net::ICal::Duration; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
15
|
|
|
29
|
1
|
|
|
1
|
|
1059
|
use Net::ICal::Time; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
13
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Net::ICal; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# 5 minutes after the end of the event or to-do |
|
36
|
|
|
|
|
|
|
# DURATION is the default type, so it's optional |
|
37
|
|
|
|
|
|
|
$t = new Net::ICal::Trigger (300); |
|
38
|
|
|
|
|
|
|
$t = new Net::ICal::Trigger (new Net::ICal::Duration ("PT5M"), |
|
39
|
|
|
|
|
|
|
related => 'END'); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# trigger for 7:30am, Jan 1st 2000 |
|
42
|
|
|
|
|
|
|
$t = new Net::ICal::Trigger (new Net::ICal::Time ('20000101T073000')); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Triggers are time markers, used most commonly for Alarms. They're attached to |
|
47
|
|
|
|
|
|
|
Times or Durations. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=begin testing |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
use lib './lib'; |
|
52
|
|
|
|
|
|
|
use Net::ICal; |
|
53
|
|
|
|
|
|
|
$duration = Net::ICal::Duration->new ('PT5M'); |
|
54
|
|
|
|
|
|
|
$datetime = Net::ICal::Time->new (ical => '20000101T073000'); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=end testing |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 new |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=for testing |
|
63
|
|
|
|
|
|
|
ok(Net::ICal::Trigger->new (300), "Create from integer number of seconds"); |
|
64
|
|
|
|
|
|
|
ok(Net::ICal::Trigger->new ($duration), "Create from a Net::ICal::Duration"); |
|
65
|
|
|
|
|
|
|
ok(Net::ICal::Trigger->new ($datetime), "Create from a Net::ICal::Time"); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new { |
|
70
|
0
|
|
|
0
|
1
|
|
my ($class, $content, %args) = @_; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $ref = ref ($content); |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
unless ($ref) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if ($content =~ /^[\+-]?P/) { |
|
|
|
0
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
%args = (content => new Net::ICal::Duration ($content)); |
|
77
|
|
|
|
|
|
|
} elsif ($content =~ /T/) { |
|
78
|
0
|
|
|
|
|
|
%args = (value => 'DATE-TIME', |
|
79
|
|
|
|
|
|
|
content => new Net::ICal::Time (ical => $content)); |
|
80
|
|
|
|
|
|
|
} else { |
|
81
|
|
|
|
|
|
|
# explicitly set everything to default |
|
82
|
0
|
|
|
|
|
|
%args = (value => 'DURATION', |
|
83
|
|
|
|
|
|
|
related => 'START', |
|
84
|
|
|
|
|
|
|
content => Net::ICal::Duration->new ($content)); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} elsif ($ref eq 'Net::ICal::Duration') { |
|
87
|
0
|
|
|
|
|
|
%args = (content => $content); |
|
88
|
|
|
|
|
|
|
} elsif ($ref eq 'Net::ICal::Time') { |
|
89
|
0
|
|
|
|
|
|
%args = (content => $content, |
|
90
|
|
|
|
|
|
|
value => 'DATE-TIME'); |
|
91
|
|
|
|
|
|
|
} else { |
|
92
|
0
|
|
|
|
|
|
warn "Argument $content is not a valid Duration or Time"; |
|
93
|
0
|
|
|
|
|
|
return undef; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
0
|
|
|
|
|
|
return &_create ($class, %args); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _create { |
|
99
|
0
|
|
|
0
|
|
|
my ($class, %args) = @_; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 value([$value]) |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Get or set the type of the trigger. Valid options are |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item DURATION |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item DATE-TIME |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 related ([$related]) |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Get or set the relation of this alarm to the Event or Todo it is |
|
118
|
|
|
|
|
|
|
related to. This is only used for alarms that are related to |
|
119
|
|
|
|
|
|
|
an Event or Todo component, and its value must be a Duration. |
|
120
|
|
|
|
|
|
|
Valid options are |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over 4 |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item START |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The Duration is relative to the start of the Event or Todo's Period |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item END |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
The Duration is relative to the end of the Event or Todo's Period |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $map = { |
|
137
|
|
|
|
|
|
|
value => { |
|
138
|
|
|
|
|
|
|
type => 'parameter', |
|
139
|
|
|
|
|
|
|
doc => 'the type of trigger', |
|
140
|
|
|
|
|
|
|
domain => 'enum', |
|
141
|
|
|
|
|
|
|
options => ['DURATION', 'DATE-TIME'], |
|
142
|
|
|
|
|
|
|
}, |
|
143
|
|
|
|
|
|
|
content => { |
|
144
|
|
|
|
|
|
|
type => 'volatile', |
|
145
|
|
|
|
|
|
|
doc => 'the value of the trigger', |
|
146
|
|
|
|
|
|
|
domain => 'reclass', |
|
147
|
|
|
|
|
|
|
options => { qr/^[^P]+$/ => 'Net::ICal::Time', |
|
148
|
|
|
|
|
|
|
default => 'Net::ICal::Duration'}, |
|
149
|
|
|
|
|
|
|
value => undef, |
|
150
|
|
|
|
|
|
|
}, |
|
151
|
|
|
|
|
|
|
related => { |
|
152
|
|
|
|
|
|
|
type => 'parameter', |
|
153
|
|
|
|
|
|
|
doc => 'whether this trigger-duration is related to the start or end of the corresponding event/to-do', |
|
154
|
|
|
|
|
|
|
domain => 'enum', |
|
155
|
|
|
|
|
|
|
options => [qw(START END)], |
|
156
|
|
|
|
|
|
|
}, |
|
157
|
|
|
|
|
|
|
}; |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new ('TRIGGER', $map, %args); |
|
160
|
0
|
|
|
|
|
|
return $self; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
|
165
|
|
|
|
|
|
|
__END__ |