line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OurCal::Provider::Multi; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1088
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use OurCal::Provider; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
OurCal::Provider::Multi - aggregate multiple providers |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
[a_multi_provider] |
14
|
|
|
|
|
|
|
providers = something another |
15
|
|
|
|
|
|
|
type = multi |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 CONFIG OPTIONS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=over 3 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=item providers |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
A space separated list of other provider names |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=back |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Requires an C object as config param and a name param. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
38
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
39
|
0
|
|
|
|
|
|
my %what = @_; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# get all the names of of our providers |
42
|
0
|
|
|
|
|
|
my $conf = $what{config}->config($what{name}); |
43
|
0
|
|
|
|
|
|
my $providers = $conf->{providers}; |
44
|
0
|
|
|
|
|
|
my $default = 0; |
45
|
0
|
|
|
|
|
|
foreach my $provider (split ' ', $providers) { |
46
|
0
|
|
|
|
|
|
$what{_providers}->{$provider} = OurCal::Provider->load_provider($provider, $what{config}); |
47
|
0
|
0
|
|
|
|
|
$default = 1 if $provider eq 'default'; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
return bless \%what, $class; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub todos { |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
return $self->_gather('todos'); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub providers { |
58
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
return values %{$self->{_providers}}; |
|
0
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub has_events { |
63
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
my %opts = @_; |
65
|
0
|
|
|
|
|
|
foreach my $provider ($self->providers) { |
66
|
0
|
0
|
|
|
|
|
return 1 if $provider->has_events(%opts); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
|
return 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub events { |
72
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my %opts = @_; |
74
|
0
|
|
|
|
|
|
my @events = sort { $b->date cmp $a->date } $self->_gather('events', %opts); |
|
0
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
@events = splice @events, 0, $opts{limit} if defined $opts{limit}; |
76
|
0
|
|
|
|
|
|
return @events; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub users { |
80
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
81
|
0
|
|
|
|
|
|
return $self->_gather('users', @_); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _gather { |
85
|
0
|
|
|
0
|
|
|
my $self = shift; |
86
|
0
|
|
|
|
|
|
my $sub = shift; |
87
|
0
|
|
|
|
|
|
my %opts = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my @vals; |
90
|
0
|
|
|
|
|
|
foreach my $provider ($self->providers) { |
91
|
0
|
|
|
|
|
|
push @vals, $provider->$sub(%opts); |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
return @vals; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub save_todo { |
98
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
99
|
0
|
|
|
|
|
|
return $self->_do_default('save_todo', @_); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub del_todo { |
103
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
104
|
0
|
|
|
|
|
|
return $self->_do_default('del_todo', @_); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub save_event { |
109
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
110
|
0
|
|
|
|
|
|
return $self->_do_default('save_event', @_); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub del_event { |
114
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
115
|
0
|
|
|
|
|
|
return $self->_do_default('del_event', @_); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _do_default { |
119
|
0
|
|
|
0
|
|
|
my $self = shift; |
120
|
0
|
|
|
|
|
|
my $sub = shift; |
121
|
0
|
|
|
|
|
|
my $thing = shift; |
122
|
0
|
0
|
|
|
|
|
die "You must specify at least one provider named 'default' if you want to save\n" |
123
|
|
|
|
|
|
|
unless $self->{_providers}->{default}; |
124
|
0
|
|
|
|
|
|
$self->{_providers}->{default}->$sub($thing); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 todos |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Returns all the todos on the system. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 has_events |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns whether there are events given the params. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 events |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns all the events for the given params. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 users |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns the name of all the users on the system. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 save_todo |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Save a todo. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 del_todo |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Delete a todo. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 save_event |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Save an event. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 del_event |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Delete an event.. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |
165
|
|
|
|
|
|
|
|