summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Process
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-02-17 03:07:55 +0000
committerfukachan <fukachan>2002-02-17 03:07:55 +0000
commitab2ef9ed7dcb834731c6a853c246fe5de6f8cc72 (patch)
tree42f936400436188af258a88b4ac257befa8def90 /fml/lib/FML/Process
parent6c32f087e4c064b9c678a086d1bd1d5df9f5e756 (diff)
downloadfml8-ab2ef9ed7dcb834731c6a853c246fe5de6f8cc72.tar.gz
fml8-ab2ef9ed7dcb834731c6a853c246fe5de6f8cc72.tar.bz2
fml8-ab2ef9ed7dcb834731c6a853c246fe5de6f8cc72.zip
implement several hooks
Diffstat (limited to 'fml/lib/FML/Process')
-rw-r--r--fml/lib/FML/Process/Command.pm30
-rw-r--r--fml/lib/FML/Process/ConfViewer.pm62
-rw-r--r--fml/lib/FML/Process/Configure.pm47
-rw-r--r--fml/lib/FML/Process/Distribute.pm29
-rw-r--r--fml/lib/FML/Process/DocViewer.pm53
-rw-r--r--fml/lib/FML/Process/HTMLify.pm31
-rw-r--r--fml/lib/FML/Process/ThreadTrack.pm59
7 files changed, 287 insertions, 24 deletions
diff --git a/fml/lib/FML/Process/Command.pm b/fml/lib/FML/Process/Command.pm
index e167ace4..1ebbec64 100644
--- a/fml/lib/FML/Process/Command.pm
+++ b/fml/lib/FML/Process/Command.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Command.pm,v 1.30 2002/02/11 12:29:27 fukachan Exp $
+# $FML: Command.pm,v 1.31 2002/02/13 10:39:33 fukachan Exp $
#
package FML::Process::Command;
@@ -75,7 +75,14 @@ forward the request to SUPER CLASS.
sub prepare
{
my ($self, $args) = @_;
+
+ my $eval = $config->get_hook( 'command_prepare_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$self->SUPER::prepare($args);
+
+ $eval = $config->get_hook( 'command_prepare_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -93,7 +100,14 @@ verify the sender is a valid member or not.
sub verify_request
{
my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'command_verify_request_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$curproc->verify_sender_credential();
+
+ $eval = $config->get_hook( 'command_verify_request_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -162,8 +176,14 @@ sub finish
{
my ($curproc, $args) = @_;
+ my $eval = $config->get_hook( 'command_finish_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$curproc->inform_reply_messages();
$curproc->queue_flush();
+
+ $eval = $config->get_hook( 'command_finish_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -293,6 +313,9 @@ sub _evaluate_command
my @body = split(/\n/, $body);
my $id = $curproc->_pre_scan( \@body ); # confirmation reply ?
+ my $eval = $config->get_hook( 'command_run_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$curproc->reply_message("result for your command requests follows:");
COMMAND:
@@ -310,7 +333,7 @@ sub _evaluate_command
# Case: not "confirm" reply message.
# check whether we need to accpet this command ?
# we accpet commands from ML members only by default.
- #
+ #
# validate general command except for confirmation
# if $id is 1, this message must be confirmation reply.
unless ($command =~ /$keyword/ && defined($id)) {
@@ -363,6 +386,9 @@ sub _evaluate_command
}
}
} # END OF FOR LOOP: for my $command (@body) { ... }
+
+ $eval = $config->get_hook( 'command_run_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
diff --git a/fml/lib/FML/Process/ConfViewer.pm b/fml/lib/FML/Process/ConfViewer.pm
index bb5d87a1..01a59f43 100644
--- a/fml/lib/FML/Process/ConfViewer.pm
+++ b/fml/lib/FML/Process/ConfViewer.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: ConfViewer.pm,v 1.6 2001/12/22 09:21:09 fukachan Exp $
+# $FML: ConfViewer.pm,v 1.7 2001/12/22 14:25:24 fukachan Exp $
#
package FML::Process::ConfViewer;
@@ -11,7 +11,7 @@ package FML::Process::ConfViewer;
use vars qw($debug @ISA @EXPORT @EXPORT_OK);
use strict;
use Carp;
-
+use FML::Log qw(Log LogWarn LogError);
use FML::Process::Kernel;
@ISA = qw(FML::Process::Kernel);
@@ -61,7 +61,22 @@ sub new
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
-sub prepare { ; }
+sub prepare
+{
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'fmlconf_prepare_start_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
+
+ $eval = $config->get_hook( 'fmlconf_prepare_end_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
+}
# Descriptions: check @ARGV, call help() if needed
@@ -74,10 +89,22 @@ sub verify_request
my ($curproc, $args) = @_;
my $argv = $curproc->command_line_argv();
+ my $eval = $config->get_hook( 'fmlconf_verify_request_start_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
+
if (length(@$argv) == 0) {
$curproc->help();
exit(0);
}
+
+ $eval = $config->get_hook( 'fmlconf_verify_request_end_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
}
@@ -108,7 +135,19 @@ sub run
my $myname = $curproc->myname();
my $argv = $curproc->command_line_argv();
+ my $eval = $config->get_hook( 'fmlconf_run_start_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
+
$curproc->_fmlconf($args);
+
+ $eval = $config->get_hook( 'fmlconf_run_end_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
}
@@ -144,7 +183,22 @@ _EOF_
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
-sub finish { 1;}
+sub finish
+{
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'fmlconf_finish_start_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
+
+ $eval = $config->get_hook( 'fmlconf_finish_end_hook' );
+ if ($eval) {
+ eval qq{ $eval; };
+ print STDERR $@ if $@;
+ }
+}
=head2 C<_fmlconf($args)> (INTERNAL USE)
diff --git a/fml/lib/FML/Process/Configure.pm b/fml/lib/FML/Process/Configure.pm
index b6ea473c..cbf27d50 100644
--- a/fml/lib/FML/Process/Configure.pm
+++ b/fml/lib/FML/Process/Configure.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Configure.pm,v 1.34 2001/12/22 09:21:09 fukachan Exp $
+# $FML: Configure.pm,v 1.35 2001/12/22 14:25:24 fukachan Exp $
#
package FML::Process::Configure;
@@ -66,7 +66,14 @@ sub new
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
-sub prepare { ; }
+sub prepare
+{
+ my $eval = $config->get_hook( 'makefml_prepare_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'makefml_prepare_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+}
# Descriptions: check @ARGV, call help() if needed.
@@ -80,10 +87,16 @@ sub verify_request
my $argv = $curproc->command_line_argv();
my $len = $#$argv + 1;
+ my $eval = $config->get_hook( 'makefml_verify_request_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
if ($len <= 1) {
$curproc->help();
exit(0);
}
+
+ $eval = $config->get_hook( 'makefml_verify_request_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -199,6 +212,9 @@ sub _makefml
args => $args,
};
+ my $eval = $config->get_hook( 'makefml_run_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
# here we go
require FML::Command;
my $obj = new FML::Command;
@@ -220,6 +236,33 @@ sub _makefml
}
}
}
+
+ $eval = $config->get_hook( 'makefml_run_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+}
+
+
+=head2 finish()
+
+finalize.
+
+=cut
+
+
+# Descriptions: clean up in the end of the curreen process.
+# return error messages et. al.
+# Arguments: OBJ($curproc) HASH_REF($args)
+# Side Effects: queue flush
+# Return Value: none
+sub finish
+{
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'makefml_finish_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'makefml_finish_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
diff --git a/fml/lib/FML/Process/Distribute.pm b/fml/lib/FML/Process/Distribute.pm
index 70fbe48e..f9d8d2b6 100644
--- a/fml/lib/FML/Process/Distribute.pm
+++ b/fml/lib/FML/Process/Distribute.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000,2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: Distribute.pm,v 1.62 2002/01/16 13:34:00 fukachan Exp $
+# $FML: Distribute.pm,v 1.63 2002/01/16 13:43:20 fukachan Exp $
#
package FML::Process::Distribute;
@@ -74,7 +74,14 @@ forward the request to the base class.
sub prepare
{
my ($self, $args) = @_;
+
+ my $eval = $config->get_hook( 'distribute_prepare_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$self->SUPER::prepare($args);
+
+ $eval = $config->get_hook( 'distribute_prepare_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -92,8 +99,15 @@ check the mail sender and the mail loop possibility.
sub verify_request
{
my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'distribute_verify_request_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$curproc->verify_sender_credential();
$curproc->simple_loop_check();
+
+ $eval = $config->get_hook( 'distribute_verify_request_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -120,6 +134,9 @@ sub run
{
my ($curproc, $args) = @_;
+ my $eval = $config->get_hook( 'distribute_run_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$curproc->lock();
{
if ($curproc->permit_post($args)) {
@@ -130,6 +147,9 @@ sub run
}
}
$curproc->unlock();
+
+ $eval = $config->get_hook( 'distribute_run_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -172,8 +192,15 @@ sub finish
{
my ($curproc, $args) = @_;
+ my $eval = $config->get_hook( 'distribute_finish_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
$curproc->inform_reply_messages();
$curproc->queue_flush();
+
+ $eval = $config->get_hook( 'distribute_finish_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
}
diff --git a/fml/lib/FML/Process/DocViewer.pm b/fml/lib/FML/Process/DocViewer.pm
index ab5f2883..afdfa4cb 100644
--- a/fml/lib/FML/Process/DocViewer.pm
+++ b/fml/lib/FML/Process/DocViewer.pm
@@ -1,9 +1,9 @@
#-*- perl -*-
#
-# Copyright (C) 2000,2001 Ken'ichi Fukamachi
+# Copyright (C) 2000,2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: DocViewer.pm,v 1.11 2001/12/22 13:24:32 fukachan Exp $
+# $FML: DocViewer.pm,v 1.12 2001/12/22 14:40:34 fukachan Exp $
#
package FML::Process::DocViewer;
@@ -67,7 +67,16 @@ sub new
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
-sub prepare { ; }
+sub prepare
+{
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'fmldoc_prepare_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmldoc_prepare_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+}
# Descriptions: check @ARGV and show help if needed
@@ -80,10 +89,16 @@ sub verify_request
my ($curproc, $args) = @_;
my $argv = $curproc->command_line_argv();
+ my $eval = $config->get_hook( 'fmldoc_verify_request_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
if (length(@$argv) == 0) {
$curproc->help();
exit(0);
}
+
+ $eval = $config->get_hook( 'fmldoc_verify_request_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -122,6 +137,9 @@ sub _fmldoc
my $myname = $curproc->myname();
my $argv = $curproc->command_line_argv();
+ my $eval = $config->get_hook( 'fmldoc_run_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
my (@opts);
push(@opts, '-v') if $args->{ options }->{ v };
push(@opts, '-t') if $args->{ options }->{ t };
@@ -136,6 +154,9 @@ sub _fmldoc
exec 'perldoc', @opts, @$argv;
};
croak($@);
+
+ $eval = $config->get_hook( 'fmldoc_run_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -169,6 +190,30 @@ _EOF_
}
+=head2 finish()
+
+finalize.
+
+=cut
+
+
+# Descriptions: clean up in the end of the curreen process.
+# return error messages et. al.
+# Arguments: OBJ($curproc) HASH_REF($args)
+# Side Effects: queue flush
+# Return Value: none
+sub finish
+{
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'fmldoc_finish_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmldoc_finish_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+}
+
+
# dummy to avoid the error ( undefined function )
sub AUTOLOAD
{
@@ -181,7 +226,7 @@ Ken'ichi Fukamachi
=head1 COPYRIGHT
-Copyright (C) 2001 Ken'ichi Fukamachi
+Copyright (C) 2000-2002 Ken'ichi Fukamachi
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
diff --git a/fml/lib/FML/Process/HTMLify.pm b/fml/lib/FML/Process/HTMLify.pm
index 710cc12a..bba50378 100644
--- a/fml/lib/FML/Process/HTMLify.pm
+++ b/fml/lib/FML/Process/HTMLify.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2000-2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: HTMLify.pm,v 1.8 2002/02/01 12:03:56 fukachan Exp $
+# $FML: HTMLify.pm,v 1.9 2002/02/02 08:04:53 fukachan Exp $
#
package FML::Process::HTMLify;
@@ -65,7 +65,11 @@ sub new
# Return Value: none
sub prepare
{
- ;
+ my $eval = $config->get_hook( 'fmlhtmlify_prepare_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmlhtmlify_prepare_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -75,7 +79,11 @@ sub prepare
# Return Value: none
sub verify_request
{
- ;
+ my $eval = $config->get_hook( 'fmlhtmlify_verify_request_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmlhtmlify_verify_request_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -99,6 +107,9 @@ sub run
print STDERR "htmlify\t$src_dir =>\n\t\t$dst_dir\n" if $debug;
+ my $eval = $config->get_hook( 'fmlhtmlify_run_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
# prepend $opt_I as @INC
if (defined $options->{ I }) {
print STDERR "\t\tprepend $options->{ I } (\@INC)\n" if $debug;
@@ -126,6 +137,9 @@ sub run
else {
croak("no destination directory\n");
}
+
+ $eval = $config->get_hook( 'fmlhtmlify_run_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -154,7 +168,16 @@ _EOF_
# Arguments: OBJ($self) HASH_REF($args)
# Side Effects: none
# Return Value: none
-sub finish {}
+sub finish
+{
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'fmlhtmlify_finish_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmlhtmlify_finish_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+}
# Descriptions: dummy to avoid to take data from STDIN
diff --git a/fml/lib/FML/Process/ThreadTrack.pm b/fml/lib/FML/Process/ThreadTrack.pm
index be900331..6966dbdf 100644
--- a/fml/lib/FML/Process/ThreadTrack.pm
+++ b/fml/lib/FML/Process/ThreadTrack.pm
@@ -1,9 +1,9 @@
#-*- perl -*-
#
-# Copyright (C) 2000-2001,2002 Ken'ichi Fukamachi
+# Copyright (C) 2001,2002 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML: ThreadTrack.pm,v 1.20 2002/02/01 12:03:57 fukachan Exp $
+# $FML: ThreadTrack.pm,v 1.21 2002/02/04 14:15:05 fukachan Exp $
#
package FML::Process::ThreadTrack;
@@ -63,7 +63,30 @@ sub new
# Return Value: none
sub prepare
{
- ;
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'fmlthread_prepare_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmlthread_prepare_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+}
+
+
+# Descriptions: none
+# Arguments: OBJ($self) HASH_REF($args)
+# Side Effects: none.
+# Return Value: none
+sub verify_request
+{
+ my ($curproc, $args) = @_;
+ my $argv = $curproc->command_line_argv();
+
+ my $eval = $config->get_hook( 'fmlthread_verify_request_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmlthread_verify_request_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -104,6 +127,8 @@ sub run
reverse_order => (defined $options->{ reverse } ? 1 : 0),
};
+ my $eval = $config->get_hook( 'fmlthread_run_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
use Mail::ThreadTrack;
my $thread = new Mail::ThreadTrack $ttargs;
@@ -166,6 +191,9 @@ sub run
}
$curproc->unlock();
+
+ $eval = $config->get_hook( 'fmlthread_run_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
}
@@ -179,10 +207,10 @@ sub _speculate_last_id
if (-f $seq_file) {
my $st = undef;
- eval q{
+ eval q{
use File::stat;
my $st = stat($seq_file);
- $sf_last_modified =
+ $sf_last_modified =
$sf_last_modified > $st->mtime ? $sf_last_modified : $st->mtime;
};
}
@@ -191,11 +219,11 @@ sub _speculate_last_id
# true since FML::Process::Distribute updates the thread db after
# updaiteing $seq_file.
# XXX 3600 is the magic number. How long time is appropriate ?
- if (-f $seq_file &&
+ if (-f $seq_file &&
($sf_last_modified + 3600 > $db_last_modified)
) {
print STDERR "read seqfile\n"; sleep 3;
- eval q{
+ eval q{
use File::Sequence;
my $sfh = new File::Sequence { sequence_file => $seq_file };
return $sfh->get_id();
@@ -345,6 +373,23 @@ _EOF_
}
+# Descriptions: clean up in the end of the curreen process.
+# return error messages et. al.
+# Arguments: OBJ($curproc) HASH_REF($args)
+# Side Effects: queue flush
+# Return Value: none
+sub finish
+{
+ my ($curproc, $args) = @_;
+
+ my $eval = $config->get_hook( 'fmlthread_finish_start_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+
+ $eval = $config->get_hook( 'fmlthread_finish_end_hook' );
+ if ($eval) { eval qq{ $eval; }; LogWarn($@) if $@; }
+}
+
+
sub DESTROY {}