| 1 | # $Id: Plugin.pm 1356 2003-08-14 15:24:00Z richardc $ | ||||||||||||||||||||
| 2 | package Siesta::Plugin; | ||||||||||||||||||||
| 3 | 27 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 27 | ▶ | use Carp qw(croak); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 27 | ▶ | use base 'Siesta::DBI'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 27 | __PACKAGE__->set_up_table('plugin'); | |||||||||||||||||||
| 7 | 27 | __PACKAGE__->columns( TEMP => qw( member )); | |||||||||||||||||||
| 8 | 27 | __PACKAGE__->has_a( list => 'Siesta::List' ); | |||||||||||||||||||
| 9 | 27 | __PACKAGE__->has_many( prefs => 'Siesta::Pref' ); | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 7 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 12 | 7 | my $pkg = shift; | |||||||||||||||||||
| 13 | 7 | my ($name) = $pkg =~ /:([^:]+)$/; | |||||||||||||||||||
| 14 | 7 | $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 | ▶ | sub process { die "Siesta::Plugin::process called directly" } | ||||||||||||||||||
|
Subroutine
process: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 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 | ▶ | sub options { +{} } | ||||||||||||||||||
|
Subroutine
options: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =head2 ->descripton | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | return a scalar which describes your plugin | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | sub description { die "virtual" } | ||||||||||||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =head2 ->pref( $name ) | ||||||||||||||||||||
| 72 | =head2 ->pref( $name, $value ); | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 66 | ▶ | sub pref { | ||||||||||||||||||
|
Subroutine
pref: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||
| 77 | 66 | my $self = shift; | |||||||||||||||||||
| 78 | 66 | my $name = shift; | |||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 66 | ▶ | my $config = $self->options->{$name} | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | or croak "no such config option '$name'"; | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 66 | for my $member ($self->member, 0) { | |||||||||||||||||||
| 84 | 130 | ▶ | next unless defined $member; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | 67 | my %crit = ( name => $name, | |||||||||||||||||||
| 86 | plugin => $self, | ||||||||||||||||||||
| 87 | member => $member, | ||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||
| 89 | 67 | my ($pref) = Siesta::Pref->search(\%crit); | |||||||||||||||||||
| 90 | 67 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 91 | 12 | ▶ | $pref ||= Siesta::Pref->create(\%crit); | ||||||||||||||||||
|
Condition66%2/3
$pref ||= "Siesta::Pref"->create(\%crit)
MC/DC0%0/2
$pref ||= "Siesta::Pref"->create(\%crit)
$pref
"Siesta::Pref"->create(\%crit)
Truth table66%2/3
A ||= B
A= $prefB= "Siesta::Pref"->create(\%crit)
| |||||||||||||||||||||
| 92 | 12 | $pref->value( shift ); | |||||||||||||||||||
| 93 | 12 | $pref->update; | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | 67 | ▶ | return $pref->value if $pref; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | 31 | 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 | 206 | ▶ | sub promote { | ||||||||||||||||||
|
Subroutine
promote: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 108 | 206 | my $self = shift; | |||||||||||||||||||
| 109 | 206 | my $class = "Siesta::Plugin::". $self->name; | |||||||||||||||||||
| 110 | 206 | ▶ | $class->require | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 111 | or die "error '$class' $UNIVERSAL::require::ERROR"; | ||||||||||||||||||||
| 112 | 206 | $class->retrieve( $self->id ); | |||||||||||||||||||
| 113 | } | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 27 | 1; | |||||||||||||||||||
| 117 | |||||||||||||||||||||