line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Plugin.pm 1356 2003-08-14 15:24:00Z richardc $ |
2
|
|
|
|
|
|
|
package Siesta::Plugin; |
3
|
18
|
|
|
18
|
|
15152
|
use strict; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
681
|
|
4
|
18
|
|
|
18
|
|
97
|
use Carp qw(croak); |
|
18
|
|
|
|
|
33
|
|
|
18
|
|
|
|
|
1095
|
|
5
|
18
|
|
|
18
|
|
94
|
use base 'Siesta::DBI'; |
|
18
|
|
|
|
|
30
|
|
|
18
|
|
|
|
|
38511
|
|
6
|
|
|
|
|
|
|
__PACKAGE__->set_up_table('plugin'); |
7
|
|
|
|
|
|
|
__PACKAGE__->columns( TEMP => qw( member )); |
8
|
|
|
|
|
|
|
__PACKAGE__->has_a( list => 'Siesta::List' ); |
9
|
|
|
|
|
|
|
__PACKAGE__->has_many( prefs => 'Siesta::Pref' ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
7
|
|
|
7
|
1
|
7106275
|
my $pkg = shift; |
13
|
7
|
|
|
|
|
96
|
my ($name) = $pkg =~ /:([^:]+)$/; |
14
|
7
|
|
|
|
|
109
|
$pkg->create({ name => $name, @_ }); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Siesta::Plugin - base class for Siesta Plugins |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 Methods |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 ->list |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 ->user |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 ->personal |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
does this plugin also run in the personal queue. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 ->process( $message ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
C<$message> is a Siesta::Message |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Return a true value to indicate "process no further plugins". use |
40
|
|
|
|
|
|
|
this for message rejection. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
0
|
1
|
0
|
sub process { die "Siesta::Plugin::process called directly" } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 ->options |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Returns a hashref, the keys of which are the various config options a |
49
|
|
|
|
|
|
|
plugin accepts. These are: |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
description - a short description of the option |
52
|
|
|
|
|
|
|
type - string, number, list, hash, boolean (1 or 0) |
53
|
|
|
|
|
|
|
default - the default value |
54
|
|
|
|
|
|
|
widget - what widget should be used in a gui to represent this |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This should be overridden by a deriving class. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
1
|
0
|
sub options { +{} } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 ->descripton |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return a scalar which describes your plugin |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
0
|
0
|
sub description { die "virtual" } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 ->pref( $name ) |
72
|
|
|
|
|
|
|
=head2 ->pref( $name, $value ); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub pref { |
77
|
66
|
|
|
66
|
1
|
1493210
|
my $self = shift; |
78
|
66
|
|
|
|
|
141
|
my $name = shift; |
79
|
|
|
|
|
|
|
|
80
|
66
|
50
|
|
|
|
342
|
my $config = $self->options->{$name} |
81
|
|
|
|
|
|
|
or croak "no such config option '$name'"; |
82
|
|
|
|
|
|
|
|
83
|
66
|
|
|
|
|
1376
|
for my $member ($self->member, 0) { |
84
|
130
|
100
|
|
|
|
9697
|
next unless defined $member; |
85
|
67
|
|
|
|
|
326
|
my %crit = ( name => $name, |
86
|
|
|
|
|
|
|
plugin => $self, |
87
|
|
|
|
|
|
|
member => $member, |
88
|
|
|
|
|
|
|
); |
89
|
67
|
|
|
|
|
486
|
my ($pref) = Siesta::Pref->search(\%crit); |
90
|
67
|
100
|
|
|
|
78770
|
if (@_) { |
91
|
12
|
|
66
|
|
|
142
|
$pref ||= Siesta::Pref->create(\%crit); |
92
|
12
|
|
|
|
|
552121
|
$pref->value( shift ); |
93
|
12
|
|
|
|
|
5420
|
$pref->update; |
94
|
|
|
|
|
|
|
} |
95
|
67
|
100
|
|
|
|
1169099
|
return $pref->value if $pref; |
96
|
|
|
|
|
|
|
} |
97
|
31
|
|
|
|
|
343
|
return $config->{default}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 promote |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Return the Siesta::Plugin::* instance that relates to this object |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub promote { |
108
|
190
|
|
|
190
|
1
|
1869
|
my $self = shift; |
109
|
190
|
|
|
|
|
649
|
my $class = "Siesta::Plugin::". $self->name; |
110
|
190
|
50
|
|
|
|
26155
|
$class->require |
111
|
|
|
|
|
|
|
or die "error '$class' $UNIVERSAL::require::ERROR"; |
112
|
190
|
|
|
|
|
13165
|
$class->retrieve( $self->id ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|