Siesta::Plugin - base class for Siesta Plugins


Siesta documentation Contained in the Siesta distribution.

Index


Code Index:

NAME

Top

Siesta::Plugin - base class for Siesta Plugins

SYNOPSIS

Top

DESCRIPTION

Top

Methods

Top

->list

->user

->personal

does this plugin also run in the personal queue.

->process( $message );

$message is a Siesta::Message

Return a true value to indicate "process no further plugins". use this for message rejection.

->options

Returns a hashref, the keys of which are the various config options a plugin accepts. These are:

 description - a short description of the option
 type        - string, number, list, hash, boolean (1 or 0)
 default     - the default value
 widget      - what widget should be used in a gui to represent this

This should be overridden by a deriving class.

->descripton

return a scalar which describes your plugin

->pref( $name ) =head2 ->pref( $name, $value );

promote

Return the Siesta::Plugin::* instance that relates to this object


Siesta documentation Contained in the Siesta distribution.
# $Id: Plugin.pm 1356 2003-08-14 15:24:00Z richardc $
package Siesta::Plugin;
use strict;
use Carp qw(croak);
use base 'Siesta::DBI';
__PACKAGE__->set_up_table('plugin');
__PACKAGE__->columns( TEMP => qw( member ));
__PACKAGE__->has_a(   list => 'Siesta::List' );
__PACKAGE__->has_many( prefs => 'Siesta::Pref' );

sub new {
    my $pkg = shift;
    my ($name) = $pkg =~ /:([^:]+)$/;
    $pkg->create({ name => $name, @_ });
}

sub process { die "Siesta::Plugin::process called directly" }

sub options { +{} }


sub description { die "virtual" }

sub pref {
    my $self = shift;
    my $name = shift;

    my $config = $self->options->{$name}
      or croak "no such config option '$name'";

    for my $member ($self->member, 0) {
        next unless defined $member;
        my %crit = ( name   => $name,
                     plugin => $self,
                     member => $member,
                    );
        my ($pref) = Siesta::Pref->search(\%crit);
        if (@_) {
            $pref ||= Siesta::Pref->create(\%crit);
            $pref->value( shift );
            $pref->update;
        }
        return $pref->value if $pref;
    }
    return $config->{default};
}


sub promote {
    my $self = shift;
    my $class = "Siesta::Plugin::". $self->name;
    $class->require
      or die "error '$class' $UNIVERSAL::require::ERROR";
    $class->retrieve( $self->id );
}


1;